From: Frank Lahm Date: Fri, 27 May 2011 08:08:31 +0000 (+0200) Subject: Handling of ECONNRESET in DSI X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=8b9b8877d1d19d2490f691d0d4f091e4398cbd30;ds=sidebyside Handling of ECONNRESET in DSI --- diff --git a/etc/afpd/afp_dsi.c b/etc/afpd/afp_dsi.c index cb1eb19f..390039f7 100644 --- a/etc/afpd/afp_dsi.c +++ b/etc/afpd/afp_dsi.c @@ -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 */ diff --git a/include/atalk/dsi.h b/include/atalk/dsi.h index 757cedbe..6c8236d7 100644 --- a/include/atalk/dsi.h +++ b/include/atalk/dsi.h @@ -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*/, diff --git a/libatalk/dsi/dsi_stream.c b/libatalk/dsi/dsi_stream.c index 5943337d..0fec3260 100644 --- a/libatalk/dsi/dsi_stream.c +++ b/libatalk/dsi/dsi_stream.c @@ -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",