mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Fix Issue 6706: return None on connect() in case of EWOULDBLOCK/ECONNABORTED error.
This commit is contained in:
parent
8581c7e11a
commit
5ea3d0f95b
4 changed files with 70 additions and 27 deletions
21
Lib/smtpd.py
21
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue