]> arthur.barton.de Git - netatalk.git/commitdiff
Dissociated afpd sessions exit on disconnection
authorFrank Lahm <franklahm@googlemail.com>
Mon, 23 May 2011 11:06:32 +0000 (13:06 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 23 May 2011 11:06:32 +0000 (13:06 +0200)
etc/afpd/afp_dsi.c
libatalk/dsi/dsi_stream.c

index a1c7b1d0244446899fbc80c611ba2527711e76f1..301e89002505bab14836e5256c0e47009fe44382 100644 (file)
@@ -302,7 +302,8 @@ static void alarm_handler(int sig _U_)
     /* if we're in the midst of processing something, don't die. */        
     if ( !(dsi->flags & DSI_RUNNING) && (dsi->tickle >= AFPobj->options.timeout)) {
         LOG(log_error, logtype_afpd, "afp_alarm: child timed out, entering disconnected state");
-        (void)dsi_disconnect(dsi);
+        if (dsi_disconnect(dsi) != 0)
+            afp_dsi_die(EXITERR_CLNT);
         return;
     }
 
@@ -315,7 +316,8 @@ static void alarm_handler(int sig _U_)
             afp_dsi_die(EXITERR_CLNT);
         }
         LOG(log_error, logtype_afpd, "afp_alarm: connection problem, entering disconnected state");
-        (void)dsi_disconnect(dsi);
+        if (dsi_disconnect(dsi) != 0)
+            afp_dsi_die(EXITERR_CLNT);
     }
 }
 
@@ -497,7 +499,8 @@ void afp_over_dsi(AFPObj *obj)
                 continue;
             }
             /* Some error on the client connection, enter disconnected state */
-            (void)dsi_disconnect(dsi);
+            if (dsi_disconnect(dsi) != 0)
+                afp_dsi_die(EXITERR_CLNT);
 
             /* the client sometimes logs out (afp_logout) but doesn't close the DSI session */
             if (dsi->flags & DSI_AFP_LOGGED_OUT) {
@@ -629,7 +632,8 @@ void afp_over_dsi(AFPObj *obj)
 
             if (!dsi_cmdreply(dsi, err)) {
                 LOG(log_error, logtype_afpd, "dsi_cmdreply(%d): %s", dsi->socket, strerror(errno) );
-                (void)dsi_disconnect(dsi);
+                if (dsi_disconnect(dsi) != 0)
+                    afp_dsi_die(EXITERR_CLNT);
             }
             break;
 
@@ -662,7 +666,8 @@ void afp_over_dsi(AFPObj *obj)
 
             if (!dsi_wrtreply(dsi, err)) {
                 LOG(log_error, logtype_afpd, "dsi_wrtreply: %s", strerror(errno) );
-                (void)dsi_disconnect(dsi);
+                if (dsi_disconnect(dsi) != 0)
+                    afp_dsi_die(EXITERR_CLNT);
             }
             break;
 
index 5c99ac2c363a084a70bffc741fcb8934ccb29844..f6d5f8b6f84c5c1125cff44f521e3ed0ed75ec07 100644 (file)
@@ -237,11 +237,15 @@ static void unblock_sig(DSI *dsi)
  *
  * 1. close the socket
  * 2. set the DSI_DISCONNECTED flag
+ *
+ * @return -1 if ppid is 1 which means afpd master died, otherwise 0
  */
 int dsi_disconnect(DSI *dsi)
 {
     dsi->proto_close(dsi);          /* 1 */
     dsi->flags |= DSI_DISCONNECTED; /* 2 */
+    if (getppid() == 1)
+        return -1;
     return 0;
 }