]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_dsi.c
netatalk: fix a crash on Solaris when registering with mDNS
[netatalk.git] / etc / afpd / afp_dsi.c
index e68b63a47e9386162c881ba8b8071b16bedec9db..e3823de594b7d3f651d203e979df400a496644ae 100644 (file)
@@ -28,6 +28,8 @@
 #include <arpa/inet.h>
 #include <setjmp.h>
 #include <time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 #include <atalk/logger.h>
 #include <atalk/dsi.h>
@@ -39,6 +41,7 @@
 #include <atalk/fce_api.h>
 #include <atalk/globals.h>
 #include <atalk/netatalk_conf.h>
+#include <atalk/spotlight.h>
 
 #include "switch.h"
 #include "auth.h"
@@ -336,6 +339,11 @@ static void alarm_handler(int sig _U_)
     }
 }
 
+static void child_handler(int sig _U_)
+{
+    wait(NULL);
+}
+
 /* ----------------- 
    if dsi->in_write is set attention, tickle (and close?) msg
    aren't sent. We don't care about tickle 
@@ -427,6 +435,17 @@ void afp_over_dsi_sighandlers(AFPObj *obj)
         afp_dsi_die(EXITERR_SYS);
     }
 #endif /* DEBUGGING */
+
+    /*  SIGCHLD */
+    action.sa_handler = child_handler;
+#ifdef SA_NOCLDWAIT
+/* this enhancement simplifies things for Solaris, it also improves performance */
+    action.sa_flags |= SA_NOCLDWAIT;
+#endif
+    if (sigaction(SIGCHLD, &action, NULL) < 0 ) {
+        LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
+        afp_dsi_die(EXITERR_SYS);
+    }
 }
 
 /* -------------------------------------------
@@ -528,7 +547,7 @@ void afp_over_dsi(AFPObj *obj)
 
         if (reload_request) {
             reload_request = 0;
-            load_volumes(AFPobj);
+            load_volumes(AFPobj, lv_force);
         }
 
         /* The first SIGINT enables debugging, the next restores the config */
@@ -622,7 +641,7 @@ void afp_over_dsi(AFPObj *obj)
                     replaycache[rc_idx].AFPcommand = function;
                     replaycache[rc_idx].result = err;
                 } else {
-                    LOG(log_error, logtype_afpd, "bad function %X", function);
+                    LOG(log_maxdebug, logtype_afpd, "bad function %X", function);
                     dsi->datalen = 0;
                     err = AFPERR_NOOP;
                 }