Skip to content

Commit

Permalink
(issue 105) look for ECONNABORTED which might be raised on FreeBSD wh…
Browse files Browse the repository at this point in the history
…en 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.
  • Loading branch information
giampaolo committed Apr 2, 2009
1 parent 0efa793 commit 0f82232
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pyftpdlib/ftpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0f82232

Please sign in to comment.