]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/util/server_child.c
First try for a volume defaults config
[netatalk.git] / libatalk / util / server_child.c
index 607c7889b0f791ebfc3d74f8397d60be6f2d45b0..59c8c7e5de657d2b0b84524e4ffc1133fb924cdc 100644 (file)
 
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
 #include <signal.h>
 #include <errno.h>
-
-/* POSIX.1 sys/wait.h check */
 #include <sys/types.h>
-#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
-#endif /* HAVE_SYS_WAIT_H */
 #include <sys/time.h>
 
 #include <atalk/logger.h>
@@ -61,8 +55,6 @@ typedef struct server_child_fork {
     void (*cleanup)(const pid_t);
 } server_child_fork;
 
-int parent_or_child; /* 0: parent, 1: child */
-
 static inline void hash_child(struct server_child_data **htable,
                               struct server_child_data *child)
 {
@@ -135,8 +127,10 @@ afp_child_t *server_child_add(server_child *children, int forkid, pid_t pid, uin
 
     /* it's possible that the child could have already died before the
      * pthread_sigmask. we need to check for this. */
-    if (kill(pid, 0) < 0)
+    if (kill(pid, 0) < 0) {
+        LOG(log_error, logtype_default, "server_child_add: no such process pid [%d]", pid);
         goto exit;
+    }
 
     fork = (server_child_fork *) children->fork + forkid;
 
@@ -282,9 +276,11 @@ int server_child_transfer_session(server_child *children,
         if (kill(pid, 0) == 0) {
             LOG(log_note, logtype_default, "Reconnect: terminating old session[%u]", pid);
             kill(pid, SIGTERM);
+            sleep(2);
             if (kill(pid, 0) == 0) {
                 LOG(log_error, logtype_default, "Reconnect: killing old session[%u]", pid);
                 kill(pid, SIGKILL);
+                sleep(2);
             }
         }
         return 0;