]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/dsi/dsi_getsess.c
Close client side of IPC fd in parent
[netatalk.git] / libatalk / dsi / dsi_getsess.c
index f7b89c8e1cf3deee9e21402bcea3be109226cc35..93d22435722671ff14c0ad78118a3677dac3fe45 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
 #include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 
 /* POSIX.1 sys/wait.h check */
 #include <sys/types.h>
@@ -45,12 +45,12 @@ afp_child_t *dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval
   afp_child_t *child;
 
   if (socketpair(PF_UNIX, SOCK_STREAM, 0, ipc_fds) < 0) {
-      LOG(log_error, logtype_afpd, "dsi_getsess: %s", strerror(errno));
+      LOG(log_error, logtype_dsi, "dsi_getsess: %s", strerror(errno));
       exit( EXITERR_CLNT );
   }
 
   if (setnonblock(ipc_fds[0], 1) != 0 || setnonblock(ipc_fds[1], 1) != 0) {
-      LOG(log_error, logtype_afpd, "dsi_getsess: setnonblock: %s", strerror(errno));
+      LOG(log_error, logtype_dsi, "dsi_getsess: setnonblock: %s", strerror(errno));
       exit(EXITERR_CLNT);
   }
 
@@ -66,7 +66,7 @@ afp_child_t *dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval
   default: /* parent */
     /* using SIGQUIT is hokey, but the child might not have
      * re-established its signal handler for SIGTERM yet. */
-    if ((child = server_child_add(serv_children, CHILD_DSIFORK, pid, ipc_fds)) < 0) {
+    if ((child = server_child_add(serv_children, CHILD_DSIFORK, pid, ipc_fds[0])) ==  NULL) {
       LOG(log_error, logtype_dsi, "dsi_getsess: %s", strerror(errno));
       dsi->header.dsi_flags = DSIFL_REPLY;
       dsi->header.dsi_code = DSIERR_SERVBUSY;
@@ -74,6 +74,7 @@ afp_child_t *dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval
       dsi->header.dsi_code = DSIERR_OK;
       kill(pid, SIGQUIT);
     }
+    close(ipc_fds[1]);
     dsi->proto_close(dsi);
     return child;
   }