Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite00e2f0

Browse files
committed
fix issuepython#6589: cleanup asyncore.socket_map if smtpd.SMTPServer constructor raises an exception
1 parent10947a6 commite00e2f0

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

‎Lib/smtpd.py‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,21 @@ def __init__(self, localaddr, remoteaddr):
274274
self._localaddr=localaddr
275275
self._remoteaddr=remoteaddr
276276
asyncore.dispatcher.__init__(self)
277-
self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
278-
# try to re-use a server port if possible
279-
self.set_reuse_addr()
280-
self.bind(localaddr)
281-
self.listen(5)
282-
print>>DEBUGSTREAM, \
283-
'%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s'% (
284-
self.__class__.__name__,time.ctime(time.time()),
285-
localaddr,remoteaddr)
277+
try:
278+
self.create_socket(socket.AF_INET,socket.SOCK_STREAM)
279+
# try to re-use a server port if possible
280+
self.set_reuse_addr()
281+
self.bind(localaddr)
282+
self.listen(5)
283+
except:
284+
# cleanup asyncore.socket_map before raising
285+
self.close()
286+
raise
287+
else:
288+
print>>DEBUGSTREAM, \
289+
'%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s'% (
290+
self.__class__.__name__,time.ctime(time.time()),
291+
localaddr,remoteaddr)
286292

287293
defhandle_accept(self):
288294
conn,addr=self.accept()

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ Build
5151
Library
5252
-------
5353

54+
- Issue #6589: cleanup asyncore.socket_map in case smtpd.SMTPServer constructor
55+
raises an exception.
56+
5457
- Issue #8959: fix regression caused by using unmodified libffi
5558
library on Windows. ctypes does now again check the stack before
5659
and after calling foreign functions.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp