From 0f822329e3431ec1bc6250c03e938c65a61b2eb4 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Thu, 2 Apr 2009 16:45:23 +0000 Subject: [PATCH] (issue 105) look for ECONNABORTED which might be raised on FreeBSD when accepting() a new connection, crashing the server. Also modified that part of code so that, if some other unexpected error is raised by accept(), it is printed on stderr and the function just returns without crashing the server. --- pyftpdlib/ftpserver.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pyftpdlib/ftpserver.py b/pyftpdlib/ftpserver.py index 180504bb..384123be 100644 --- a/pyftpdlib/ftpserver.py +++ b/pyftpdlib/ftpserver.py @@ -618,10 +618,16 @@ def handle_accept(self): except TypeError: # sometimes accept() might return None (see issue 91) return + except socket.error, err: + # ECONNABORTED might be thrown on *BSD (see issue 105) + if err[0] != ECONNABORTED: + logerror(traceback.format_exc()) + return else: # sometimes addr == None instead of (ip, port) (see issue 104) if addr == None: return + # Check the origin of data connection. If not expressively # configured we drop the incoming data connection if remote # IP address does not match the client's IP address. @@ -3158,12 +3164,17 @@ def handle_accept(self): except TypeError: # sometimes accept() might return None (see issue 91) return + except socket.error, err: + # ECONNABORTED might be thrown on *BSD (see issue 105) + if err[0] != ECONNABORTED: + logerror(traceback.format_exc()) + return else: # sometimes addr == None instead of (ip, port) (see issue 104) if addr == None: return - log("[]%s:%s Connected." %addr[:2]) + log("[]%s:%s Connected." %addr[:2]) handler = self.handler(sock, self) if not handler.connected: return