X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=server.c;h=334787241e3952b2462485fee68c7882f313e967;hb=cf1e416e5db97f1673521a63dacaa1487fb875d7;hp=94e6564b783371fb8cd77e9f8c0a96eb55093f6f;hpb=cb6d1dfb9e4067229a4bbde0abd05784d97ef14b;p=paraslash.git diff --git a/server.c b/server.c index 94e6564b..33478724 100644 --- a/server.c +++ b/server.c @@ -15,6 +15,9 @@ * */ +#include +#include +#include #include "para.h" #include "server.cmdline.h" @@ -31,6 +34,8 @@ #include "string.h" #include "ipc.h" #include "fd.h" +#include "list.h" +#include "sched.h" #include "signal.h" #include "user_list.h" #include "afs.h" @@ -346,7 +351,7 @@ out: exit(EXIT_FAILURE); } -static uint32_t afs_socket_cookie; +uint32_t afs_socket_cookie; static int afs_socket; pid_t afs_pid; @@ -361,10 +366,16 @@ static void init_afs(void) 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]); + } 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); }