]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/main.c
AFP 3.x add sleep timeout, add disconnect old session. Björn Fernhomberg and me
[netatalk.git] / etc / afpd / main.c
index 91ad85e9909afa52a0d31b2f8b7114fb1a1151a0..f31dd8440a84e76069fb26bce4a5f9ec285a8d29 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: main.c,v 1.20 2002-10-04 15:15:05 srittau Exp $
+ * $Id: main.c,v 1.21 2003-05-16 15:29:27 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -41,6 +41,7 @@
 #include <atalk/paths.h>
 #include <atalk/util.h>
 #include <atalk/server_child.h>
+#include <atalk/server_ipc.h>
 
 #include "globals.h"
 #include "afp_config.h"
@@ -63,6 +64,7 @@ struct afp_options default_options;
 static AFPConfig *configs;
 static server_child *server_children;
 static fd_set save_rfds;
+static int    Ipc_fd = -1;
 
 #ifdef TRU64
 void afp_get_cmdline( int *ac, char ***av)
@@ -78,6 +80,25 @@ static void afp_exit(const int i)
     exit(i);
 }
 
+/* ------------------ 
+   initialize fd set we are waiting for.
+*/
+static void set_fd(int ipc_fd)
+{
+    AFPConfig   *config;
+    
+    FD_ZERO(&save_rfds);
+    for (config = configs; config; config = config->next) {
+        if (config->fd < 0) /* for proxies */
+            continue;
+        FD_SET(config->fd, &save_rfds);
+    }
+    if (ipc_fd >= 0) {
+        FD_SET(ipc_fd, &save_rfds);
+    }
+}
+
+/* ------------------ */
 static void afp_goaway(int sig)
 {
 #ifndef NO_DDP
@@ -104,12 +125,7 @@ static void afp_goaway(int sig)
                 LOG(log_error, logtype_afpd, "config re-read: no servers configured");
                 afp_exit(1);
             }
-            FD_ZERO(&save_rfds);
-            for (config = configs; config; config = config->next) {
-                if (config->fd < 0)
-                    continue;
-                FD_SET(config->fd, &save_rfds);
-            }
+            set_fd(Ipc_fd);
         } else {
             LOG(log_info, logtype_afpd, "disallowing logins");
             auth_unload();
@@ -141,6 +157,7 @@ char        **av;
 {
     AFPConfig           *config;
     fd_set              rfds;
+    void                *ipc;
     struct sigaction   sv;
     sigset_t            sigs;
 
@@ -218,13 +235,11 @@ char      **av;
     }
     sigprocmask(SIG_UNBLOCK, &sigs, NULL);
 
-    /* watch atp and dsi sockets. */
-    FD_ZERO(&save_rfds);
-    for (config = configs; config; config = config->next) {
-        if (config->fd < 0) /* for proxies */
-            continue;
-        FD_SET(config->fd, &save_rfds);
+    /* watch atp, dsi sockets and ipc parent/child file descriptor. */
+    if ((ipc = server_ipc_create())) {
+        Ipc_fd = server_ipc_parent(ipc);
     }
+    set_fd(Ipc_fd);
 
     /* wait for an appleshare connection. parent remains in the loop
      * while the children get handled by afp_over_{asp,dsi}.  this is
@@ -240,7 +255,9 @@ char        **av;
             LOG(log_error, logtype_afpd, "main: can't wait for input: %s", strerror(errno));
             break;
         }
-
+        if (Ipc_fd >=0 && FD_ISSET(Ipc_fd, &rfds)) {
+            server_ipc_read(server_children);
+       }
         for (config = configs; config; config = config->next) {
             if (config->fd < 0)
                 continue;