mirror of https://github.com/python/cpython.git
fix issue #6589: cleanup asyncore.socket_map if smtpd.SMTPServer constructor raises an exception
This commit is contained in:
parent
10947a6416
commit
e00e2f0082
24
Lib/smtpd.py
24
Lib/smtpd.py
|
@ -274,15 +274,21 @@ def __init__(self, localaddr, remoteaddr):
|
||||||
self._localaddr = localaddr
|
self._localaddr = localaddr
|
||||||
self._remoteaddr = remoteaddr
|
self._remoteaddr = remoteaddr
|
||||||
asyncore.dispatcher.__init__(self)
|
asyncore.dispatcher.__init__(self)
|
||||||
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
try:
|
||||||
# try to re-use a server port if possible
|
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.set_reuse_addr()
|
# try to re-use a server port if possible
|
||||||
self.bind(localaddr)
|
self.set_reuse_addr()
|
||||||
self.listen(5)
|
self.bind(localaddr)
|
||||||
print >> DEBUGSTREAM, \
|
self.listen(5)
|
||||||
'%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % (
|
except:
|
||||||
self.__class__.__name__, time.ctime(time.time()),
|
# cleanup asyncore.socket_map before raising
|
||||||
localaddr, remoteaddr)
|
self.close()
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
print >> DEBUGSTREAM, \
|
||||||
|
'%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % (
|
||||||
|
self.__class__.__name__, time.ctime(time.time()),
|
||||||
|
localaddr, remoteaddr)
|
||||||
|
|
||||||
def handle_accept(self):
|
def handle_accept(self):
|
||||||
conn, addr = self.accept()
|
conn, addr = self.accept()
|
||||||
|
|
|
@ -51,6 +51,9 @@ Build
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #6589: cleanup asyncore.socket_map in case smtpd.SMTPServer constructor
|
||||||
|
raises an exception.
|
||||||
|
|
||||||
- Issue #8959: fix regression caused by using unmodified libffi
|
- Issue #8959: fix regression caused by using unmodified libffi
|
||||||
library on Windows. ctypes does now again check the stack before
|
library on Windows. ctypes does now again check the stack before
|
||||||
and after calling foreign functions.
|
and after calling foreign functions.
|
||||||
|
|
Loading…
Reference in New Issue