Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 934abdd

Browse files
committed
fix issue #2944: asyncore doesn't handle connection refused correctly (patch by Alexander Shigin). Merged from 2.7 branch.
1 parent 84c7d9f commit 934abdd

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/asyncore.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,11 @@ def handle_read_event(self):
435435
self.handle_read()
436436

437437
def handle_connect_event(self):
438-
self.connected = True
438+
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
439+
if err != 0:
440+
raise socket.error(err, _strerror(err))
439441
self.handle_connect()
442+
self.connected = True
440443

441444
def handle_write_event(self):
442445
if self.accepting:

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,3 +895,4 @@ Siebren van der Zee
895895
Uwe Zessin
896896
Tarek Ziadé
897897
Peter Åstrand
898+
Alexander Shigin

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Extensions
3737
Library
3838
-------
3939

40+
- Issue #2944: asyncore doesn't handle connection refused correctly.
41+
4042
- Issue #4184: Private attributes on smtpd.SMTPChannel made public and
4143
deprecate the private attributes. Add tests for smtpd module.
4244

0 commit comments

Comments
 (0)