This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix for #777597 - socketmodule.c connection handling incorec
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, troels
Priority: normal Keywords: patch

Created on 2004-06-02 13:57 by troels, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
windows_socketmodule_select_connrefused.patch troels, 2004-06-02 13:57 starting point for a fix, not complete, do not apply yet
test_socket_connrefused.patch troels, 2004-06-02 22:21 a new test_socket regression test to verify that connection refused raises a socket.error exception
windows_socketmodule_select_connrefused2.patch troels, 2004-06-08 08:42 corrected and tested fix for bug #777597, ready for application
test_socket_connrefused2.patch troels, 2004-06-09 06:58 regression test with 5 second timeout
Messages (5)
msg46109 - (view) Author: Troels Walsted Hansen (troels) Date: 2004-06-02 13:57
I took Garth Bushell's inlined code from
http://python.org/sf/777597 and produced a patch per
nnorwitz's request in the bug comments. The patch is
for Python 2.3.4.

I created the patch as a starting point for a fix. I
don't believe that this patch is the correct fix for
the problem, so it should definitely not be applied in
the current form.

One major problem is that Garth removed the writefds
fd_set, which means that the code will detect
"connection refused" and "timeout" events, but not
"connection established". The code also needs
compliation and runtime testing (maybe even a
regression test to cover this common WinSock
programming error?).

I hope to submit a fixed and tested patch soon. I'll
upload it here when it is ready.
msg46110 - (view) Author: Troels Walsted Hansen (troels) Date: 2004-06-02 22:21
Logged In: YES 
user_id=32863

OK... As promised, here is the regression test.

The test passes on Linux and fails on Windows XP with Python
2.3.4 with the error below.

I'd appreciate any comments on the test.

FAIL: testTCPConnectionRefused
(__main__.TCPConnectionRefusedTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib\test\test_socket.py", line 752, in
testTCPConnectionRefused
    self.failUnlessEqual(exc_type, socket.error)
  File "C:\Program Files\Python23\lib\unittest.py", line
302, in failUnlessEqual

    raise self.failureException, \
AssertionError: <class socket.timeout at 0x00945510> !=
<class socket.error at 0x00945480>
msg46111 - (view) Author: Troels Walsted Hansen (troels) Date: 2004-06-08 08:42
Logged In: YES 
user_id=32863

Here is the fixed patch. It compiles and passes the
regression test correctly on Windows 2003 Server.
msg46112 - (view) Author: Troels Walsted Hansen (troels) Date: 2004-06-09 06:58
Logged In: YES 
user_id=32863

Some additional testing showed that the regression test
could fail randomly. It seems that the 1 second timeout was
too low, I have uploaded a new version with a 5 second
timeout instead.
msg77044 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-12-05 17:37
A similar patch was applied 4 years ago, in r36739.
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40332
2009-02-13 03:29:43ajaksu2linkissue777597 dependencies
2008-12-05 17:37:55amaury.forgeotdarcsetstatus: open -> closed
resolution: out of date
messages: + msg77044
nosy: + amaury.forgeotdarc
2004-06-02 13:57:00troelscreate