* add a child
* @return pointer to struct server_child_data on success, NULL on error
*/
-afp_child_t *server_child_add(server_child *children, int forkid, pid_t pid, uint ipc_fds[2])
+afp_child_t *server_child_add(server_child *children, int forkid, pid_t pid, int ipc_fd)
{
server_child_fork *fork;
afp_child_t *child = NULL;
child->pid = pid;
child->valid = 0;
child->killed = 0;
- child->ipc_fds[0] = ipc_fds[0];
- child->ipc_fds[1] = ipc_fds[1];
+ child->ipc_fd = ipc_fd;
hash_child(fork->table, child);
children->count++;
}
/* In main:child_handler() we need the fd in order to remove it from the pollfd set */
- fd = child->ipc_fds[0];
- if (child->ipc_fds[0] != -1) {
- close(child->ipc_fds[0]);
- child->ipc_fds[0] = -1;
- }
- if (child->ipc_fds[1] != -1) {
- close(child->ipc_fds[1]);
- child->ipc_fds[1] = -1;
- }
+ fd = child->ipc_fd;
+ if (fd != -1)
+ close(fd);
free(child);
children->count--;
child = fork->table[j]; /* start at the beginning */
while (child) {
tmp = child->next;
+ close(child->ipc_fd);
if (child->clientid) {
free(child->clientid);
}
LOG(log_note, logtype_default, "Reconnect: transfering session to child[%u]", pid);
- if (writet(child->ipc_fds[0], &DSI_requestID, 2, 0, 2) != 2) {
+ if (writet(child->ipc_fd, &DSI_requestID, 2, 0, 2) != 2) {
LOG(log_error, logtype_default, "Reconnect: error sending DSI id to child[%u]", pid);
EC_STATUS(-1);
goto EC_CLEANUP;
}
- EC_ZERO_LOG(send_fd(child->ipc_fds[0], afp_socket));
+ EC_ZERO_LOG(send_fd(child->ipc_fd, afp_socket));
EC_ZERO_LOG(kill(pid, SIGURG));
EC_STATUS(1);