/* remove a child and free it */ int server_child_remove(server_child *children, const int forkid, pid_t pid) { int fd; server_child_fork *fork; struct server_child_data *child; fork = (server_child_fork *) children->fork + forkid; if (!(child = resolve_child(fork->table, pid))) return -1; unhash_child(child); if (child->clientid) { free(child->clientid); child->clientid = NULL; } /* In main:child_handler() we need the fd in order to remove it from the pollfd set */ fd = child->ipc_fd; if (fd != -1) close(fd); free(child); children->count--; if (fork->cleanup) fork->cleanup(pid); return fd; }
/* remove a child and free it */ int server_child_remove(server_child_t *children, pid_t pid) { int fd; afp_child_t *child; if (!(child = server_child_resolve(children, pid))) return -1; pthread_mutex_lock(&children->servch_lock); unhash_child(child); if (child->afpch_clientid) { free(child->afpch_clientid); child->afpch_clientid = NULL; } /* In main:child_handler() we need the fd in order to remove it from the pollfd set */ fd = child->afpch_ipc_fd; if (fd != -1) close(fd); free(child); children->servch_count--; pthread_mutex_unlock(&children->servch_lock); return fd; }