]> arthur.barton.de Git - netatalk.git/commitdiff
Handling of ECONNRESET in DSI
authorFrank Lahm <franklahm@googlemail.com>
Fri, 27 May 2011 08:08:31 +0000 (10:08 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 27 May 2011 08:08:31 +0000 (10:08 +0200)
etc/afpd/afp_dsi.c
include/atalk/dsi.h
libatalk/dsi/dsi_stream.c

index cb1eb19f75d8d849a5153955fb745c3de82de91e..390039f7baa2f3c2b15ef674ae04414bd1ea2f5a 100644 (file)
@@ -493,16 +493,25 @@ void afp_over_dsi(AFPObj *obj)
                 dsi->flags &= ~DSI_RECONSOCKET;
                 continue;
             }
-            /* Some error on the client connection, enter disconnected state */
-            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) {
+                LOG(log_note, logtype_afpd, "afp_over_dsi: client logged out, terminating DSI session");
                 afp_dsi_close(obj);
                 exit(0);
             }
 
+            /*  got ECONNRESET in read from client => exit*/
+            if (dsi->flags & DSI_GOT_ECONNRESET) {
+                LOG(log_note, logtype_afpd, "afp_over_dsi: client connection reset");
+                afp_dsi_close(obj);
+                exit(0);
+            }
+
+            /* Some error on the client connection, enter disconnected state */
+            if (dsi_disconnect(dsi) != 0)
+                afp_dsi_die(EXITERR_CLNT);
+
             pause(); /* gets interrupted by SIGALARM or SIGURG tickle */
             continue; /* continue receiving until disconnect timer expires
                        * or a primary reconnect succeeds  */
index 757cedbe6f7cf4b2e15c6f9987aa1e170580e8d7..6c8236d750992e84c03db2e0f28fe0ee49d27f47 100644 (file)
@@ -159,6 +159,7 @@ typedef struct DSI {
 #define DSI_RECONSOCKET      (1 << 7) /* we have a new socket from primary reconnect */
 #define DSI_RECONINPROG      (1 << 8) /* used in the new session in reconnect */
 #define DSI_AFP_LOGGED_OUT   (1 << 9) /* client called afp_logout, quit on next EOF from socket */
+#define DSI_GOT_ECONNRESET   (1 << 10) /* got ECONNRESET from client => exit */
 
 /* basic initialization: dsi_init.c */
 extern DSI *dsi_init (const dsi_proto /*protocol*/,
index 5943337d434b5e9c3ab8a8381e647aa3eef36444..0fec3260529b494bec92fbe2ebeac66be673f39f 100644 (file)
@@ -389,6 +389,8 @@ size_t dsi_stream_read(DSI *dsi, void *data, const size_t length)
           stored += len;
       } else { /* eof or error */
           /* don't log EOF error if it's just after connect (OSX 10.3 probe) */
+          if (errno == ECONNRESET)
+              dsi->flags |= DSI_GOT_ECONNRESET;
           if (len || stored || dsi->read_count) {
               if (! (dsi->flags & DSI_DISCONNECTED)) {
                   LOG(log_error, logtype_dsi, "dsi_stream_read: len:%d, %s",