summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGiampaolo RodolĂ  <g.rodola@gmail.com>2010-11-01 15:18:09 (GMT)
committerGiampaolo RodolĂ  <g.rodola@gmail.com>2010-11-01 15:18:09 (GMT)
commit5ea3d0f95b51009fa1c3409e7dd1c12006427ccc (patch)
treed532cf8a8c9b9fccd3f8cf7738a1716a4e3662f5 /Lib
parent8581c7e11a2e38c076fc3d96f30fce394ff1ce69 (diff)
downloadcpython-5ea3d0f95b51009fa1c3409e7dd1c12006427ccc.zip
cpython-5ea3d0f95b51009fa1c3409e7dd1c12006427ccc.tar.gz
cpython-5ea3d0f95b51009fa1c3409e7dd1c12006427ccc.tar.bz2
Fix Issue 6706: return None on connect() in case of EWOULDBLOCK/ECONNABORTED error.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncore.py9
-rwxr-xr-xLib/smtpd.py21
2 files changed, 11 insertions, 19 deletions
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index 7f06e43..861495d 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -346,12 +346,15 @@ class dispatcher:
# XXX can return either an address pair or None
try:
conn, addr = self.socket.accept()
- return conn, addr
+ except TypeError:
+ return None
except socket.error as why:
- if why.args[0] == EWOULDBLOCK:
- pass
+ if why.args[0] in (EWOULDBLOCK, ECONNABORTED):
+ return None
else:
raise
+ else:
+ return conn, addr
def send(self, data):
try:
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index 57ad089..ab3e0e2 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -297,22 +297,11 @@ class SMTPServer(asyncore.dispatcher):
localaddr, remoteaddr), file=DEBUGSTREAM)
def handle_accept(self):
- try:
- conn, addr = self.accept()
- except TypeError:
- # sometimes accept() might return None
- return
- except socket.error as err:
- # ECONNABORTED might be thrown
- if err.args[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 = SMTPChannel(self, conn, addr)
+ pair = self.accept()
+ if pair is not None:
+ conn, addr = pair
+ print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM)
+ channel = SMTPChannel(self, conn, addr)
# API for "doing something useful with the message"
def process_message(self, peer, mailfrom, rcpttos, data):