]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_config.c
First working IPC reconnect
[netatalk.git] / etc / afpd / afp_config.c
index 648eed71589b27bf77f0eccf7d3057db42ed7e3d..291148c3458eeeca77432d751f5813128620d198 100644 (file)
@@ -36,7 +36,7 @@
 #include <atalk/ldapconfig.h>
 #endif
 
-#include "globals.h"
+#include <atalk/globals.h>
 #include "afp_config.h"
 #include "uam_auth.h"
 #include "status.h"
@@ -214,25 +214,30 @@ static int asp_start(AFPConfig *config, AFPConfig *configs,
 }
 #endif /* no afp/asp */
 
-static int dsi_start(AFPConfig *config, AFPConfig *configs,
-                     server_child *server_children)
+static afp_child_t *dsi_start(AFPConfig *config, AFPConfig *configs,
+                              server_child *server_children)
 {
-    DSI *dsi;
+    DSI *dsi = config->obj.handle;
+    afp_child_t *child = NULL;
 
-    if (!(dsi = dsi_getsession(config->obj.handle, server_children,
-                               config->obj.options.tickleval))) {
-        LOG(log_error, logtype_afpd, "main: dsi_getsession: %s", strerror(errno) );
-        exit( EXITERR_CLNT );
+    if (!(child = dsi_getsession(dsi,
+                                 server_children,
+                                 config->obj.options.tickleval))) {
+        LOG(log_error, logtype_afpd, "dsi_start: session error: %s", strerror(errno));
+        return NULL;
     }
 
     /* we've forked. */
-    if (dsi->child) {
+    if (parent_or_child == 1) {
         configfree(configs, config);
+        config->obj.ipc_fd = child->ipc_fds[1];
+        close(child->ipc_fds[0]); /* Close parent IPC fd */
+        free(child);
         afp_over_dsi(&config->obj); /* start a session */
         exit (0);
     }
 
-    return 0;
+    return child;
 }
 
 #ifndef NO_DDP
@@ -357,6 +362,7 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
         free(config);
         return NULL;
     }
+    dsi->dsireadbuf = options->dsireadbuf;
 
     if (options->flags & OPTION_PROXY) {
         LOG(log_note, logtype_afpd, "AFP/TCP proxy initialized for %s:%d (%s)",
@@ -585,8 +591,10 @@ AFPConfig *configinit(struct afp_options *cmdline)
         first = AFPConfigInit(cmdline, cmdline);
 
     /* Now register with zeroconf, we also need the volumes for that */
-    load_volumes(&first->obj);
-    zeroconf_register(first);
+    if (! (first->obj.options.flags & OPTION_NOZEROCONF)) {
+        load_volumes(&first->obj);
+        zeroconf_register(first);
+    }
 
     return first;
 }