Merge branch 'maint'
[paraslash.git] / server.c
index 2455626..f7aad89 100644 (file)
--- a/server.c
+++ b/server.c
@@ -64,6 +64,7 @@
 #include <dirent.h>
 #include <sys/time.h>
 #include <openssl/rc4.h>
+#include <regex.h>
 #include <osl.h>
 
 #include "para.h"
@@ -438,19 +439,21 @@ err:
 static int init_afs(void)
 {
        int ret, afs_server_socket[2];
+       pid_t afs_pid;
 
        ret = socketpair(PF_UNIX, SOCK_DGRAM, 0, afs_server_socket);
        if (ret < 0)
                exit(EXIT_FAILURE);
        get_random_bytes_or_die((unsigned char *)&afs_socket_cookie,
                sizeof(afs_socket_cookie));
-       mmd->afs_pid = fork();
-       if (mmd->afs_pid < 0)
+       afs_pid = fork();
+       if (afs_pid < 0)
                exit(EXIT_FAILURE);
-       if (!mmd->afs_pid) { /* child (afs) */
+       if (afs_pid == 0) { /* child (afs) */
                close(afs_server_socket[0]);
                afs_init(afs_socket_cookie, afs_server_socket[1]);
        }
+       mmd->afs_pid = afs_pid;
        close(afs_server_socket[1]);
        ret = mark_fd_nonblocking(afs_server_socket[0]);
        if (ret < 0)