summaryrefslogtreecommitdiff
path: root/Lib/smtpd.py
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-21 18:35:05 +0000
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2010-08-21 18:35:05 +0000
commit5c8c9a2c330db5a96eb1149d388b411e7ec5acd3 (patch)
tree1f224318ee94ec3eff10df60c90b82f982741f0e /Lib/smtpd.py
parent6cbe4275cbb48ae4161143f8b97636fc19f678e5 (diff)
downloadcpython-git-5c8c9a2c330db5a96eb1149d388b411e7ec5acd3.tar.gz
fix issue #9129: added proper error handling when accepting new connections in SMTPServer.handle_accept
Diffstat (limited to 'Lib/smtpd.py')
-rwxr-xr-xLib/smtpd.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index b4082786fa..e8459f0920 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -413,8 +413,21 @@ class SMTPServer(asyncore.dispatcher):
self.__class__.__name__, time.ctime(time.time()),
localaddr, remoteaddr), file=DEBUGSTREAM)
- def handle_accept(self):
- conn, addr = self.accept()
+ def handle_accept(self)
+ try:
+ conn, addr = self.accept()
+ except TypeError:
+ # sometimes accept() might return None
+ return
+ except socket.error, err:
+ # ECONNABORTED might be thrown
+ if err[0] != errno.ECONNABORTED:
+ raise
+ return
+ else:
+ # sometimes addr == None instead of (ip, port)
+ if addr == None:
+ return
print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM)
channel = self.channel_class(self, conn, addr)