void __conhash_del_replicas(struct conhash_s *conhash, struct node_s *node) { u_int i, len; long hash; char buff[128]; struct virtual_node_s *vnode; util_rbtree_node_t *rbnode; for(i = 0; i < node->replicas; i++) { /* calc hash value of all virtual nodes */ __conhash_node2string(node, i, buff, &len); hash = conhash->cb_hashfunc(buff); rbnode = util_rbtree_search(&(conhash->vnode_tree), hash); if(rbnode != NULL) { vnode = (struct virtual_node_s*)rbnode->data; if((vnode->hash == hash) && (vnode->node == node)) { conhash->ivnodes--; util_rbtree_delete(&(conhash->vnode_tree), rbnode); __conhash_del_rbnode(rbnode); } } } }
void conhash_fini(struct conhash_s *conhash) { if(conhash != NULL) { /* free rb tree */ while(!util_rbtree_isempty(&(conhash->vnode_tree))) { util_rbtree_node_t *rbnode = conhash->vnode_tree.root; util_rbtree_delete(&(conhash->vnode_tree), rbnode); __conhash_del_rbnode(rbnode); } free(conhash); } }