]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - server.c
afs.c: Fix documentation of stdin_command().
[paraslash.git] / server.c
index a63aeefc357fe95e54386414390a5a951f2dc91f..d98e9603ced15a27ea1780ffb7ef850e5138c55e 100644 (file)
--- a/server.c
+++ b/server.c
@@ -15,6 +15,8 @@
  *
  */
 
  *
  */
 
+#include <sys/types.h>
+#include <dirent.h>
 
 #include "para.h"
 #include "server.cmdline.h"
 
 #include "para.h"
 #include "server.cmdline.h"
@@ -348,7 +350,7 @@ out:
        exit(EXIT_FAILURE);
 }
 
        exit(EXIT_FAILURE);
 }
 
-static uint32_t afs_socket_cookie;
+uint32_t afs_socket_cookie;
 static int afs_socket;
 pid_t afs_pid;
 
 static int afs_socket;
 pid_t afs_pid;
 
@@ -363,10 +365,16 @@ static void init_afs(void)
        afs_pid = fork();
        if (afs_pid < 0)
                exit(EXIT_FAILURE);
        afs_pid = fork();
        if (afs_pid < 0)
                exit(EXIT_FAILURE);
-       if (!afs_pid) /* child (afs) */
+       if (!afs_pid) { /* child (afs) */
+               close(afs_server_socket[0]);
                afs_init(afs_socket_cookie, afs_server_socket[1]);
                afs_init(afs_socket_cookie, afs_server_socket[1]);
+       }
        close(afs_server_socket[1]);
        afs_socket = afs_server_socket[0];
        close(afs_server_socket[1]);
        afs_socket = afs_server_socket[0];
+       ret = mark_fd_nonblock(afs_socket);
+       if (ret < 0)
+               exit(EXIT_FAILURE);
+       add_close_on_fork_list(afs_socket);
        PARA_INFO_LOG("afs_socket: %d, afs_socket_cookie: %u\n", afs_socket,
                (unsigned) afs_socket_cookie);
 }
        PARA_INFO_LOG("afs_socket: %d, afs_socket_cookie: %u\n", afs_socket,
                (unsigned) afs_socket_cookie);
 }