static int destroy_zkrb_instance(struct zkrb_instance_data* ptr) { int rv = ZOK; if (ptr->zh) { const void *ctx = zoo_get_context(ptr->zh); /* Note that after zookeeper_close() returns, ZK handle is invalid */ rv = zookeeper_close(ptr->zh); free((void *) ctx); } #warning [wickman] TODO: fire off warning if queue is not empty if (ptr->queue) zkrb_queue_free(ptr->queue); ptr->zh = NULL; ptr->queue = NULL; return rv; }
static int destroy_zkrb_instance(struct zkrb_instance_data* ptr) { int rv = ZOK; if (ptr->zh) { const void *ctx = zoo_get_context(ptr->zh); /* Note that after zookeeper_close() returns, ZK handle is invalid */ zkrb_debug("obj_id: %lx, calling zookeeper_close", ptr->object_id); rv = zookeeper_close(ptr->zh); zkrb_debug("obj_id: %lx, zookeeper_close returned %d", ptr->object_id, rv); free((void *) ctx); } #warning [wickman] TODO: fire off warning if queue is not empty if (ptr->queue) { zkrb_debug("obj_id: %lx, freeing queue pointer: %p", ptr->object_id, ptr->queue); zkrb_queue_free(ptr->queue); } ptr->zh = NULL; ptr->queue = NULL; return rv; }
static int destroy_zkrb_instance(zkrb_instance_data_t* zk) { int rv = ZOK; zkrb_debug("destroy_zkrb_instance, zk_local_ctx: %p, zh: %p, queue: %p", zk, zk->zh, zk->queue); if (zk->zh) { const void *ctx = zoo_get_context(zk->zh); /* Note that after zookeeper_close() returns, ZK handle is invalid */ zkrb_debug("obj_id: %lx, calling zookeeper_close", zk->object_id); if (we_are_forked(zk)) { zkrb_debug("FORK DETECTED! orig_pid: %d, current pid: %d, " "using socket-closing hack before zookeeper_close", zk->orig_pid, getpid()); int fd = ((int *)zk->zh)[0]; // nasty, brutish, and wonderfully effective hack (see above) close(fd); } rv = zookeeper_close(zk->zh); zkrb_debug("obj_id: %lx, zookeeper_close returned %d, calling context: %p", zk->object_id, rv, ctx); zkrb_calling_context_free((zkrb_calling_context *) ctx); } zk->zh = NULL; if (zk->queue) { zkrb_debug("obj_id: %lx, freeing queue pointer: %p", zk->object_id, zk->queue); zkrb_queue_free(zk->queue); } zk->queue = NULL; return rv; }