Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #777597 - socketmodule.c connection handling incorec #40332

Closed
troels mannequin opened this issue Jun 2, 2004 · 5 comments
Closed

Fix for #777597 - socketmodule.c connection handling incorec #40332

troels mannequin opened this issue Jun 2, 2004 · 5 comments
Labels
extension-modules C modules in the Modules dir

Comments

@troels
Copy link
Mannequin

troels mannequin commented Jun 2, 2004

BPO 965036
Nosy @amauryfa
Files
  • windows_socketmodule_select_connrefused.patch: starting point for a fix, not complete, do not apply yet
  • test_socket_connrefused.patch: a new test_socket regression test to verify that connection refused raises a socket.error exception
  • windows_socketmodule_select_connrefused2.patch: corrected and tested fix for bug socketmodule.c connection handling incorect on windows #38930, ready for application
  • test_socket_connrefused2.patch: regression test with 5 second timeout
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2008-12-05.17:37:55.494>
    created_at = <Date 2004-06-02.13:57:00.000>
    labels = ['extension-modules']
    title = 'Fix for python/cpython#38930 - socketmodule.c connection handling incorec'
    updated_at = <Date 2008-12-05.17:37:55.465>
    user = 'https://bugs.python.org/troels'

    bugs.python.org fields:

    activity = <Date 2008-12-05.17:37:55.465>
    actor = 'amaury.forgeotdarc'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-12-05.17:37:55.494>
    closer = 'amaury.forgeotdarc'
    components = ['Extension Modules']
    creation = <Date 2004-06-02.13:57:00.000>
    creator = 'troels'
    dependencies = []
    files = ['6008', '6009', '6010', '6011']
    hgrepos = []
    issue_num = 965036
    keywords = ['patch']
    message_count = 5.0
    messages = ['46109', '46110', '46111', '46112', '77044']
    nosy_count = 2.0
    nosy_names = ['troels', 'amaury.forgeotdarc']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue965036'
    versions = ['Python 2.3']

    @troels
    Copy link
    Mannequin Author

    troels mannequin commented Jun 2, 2004

    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.

    @troels troels mannequin added extension-modules C modules in the Modules dir labels Jun 2, 2004
    @troels
    Copy link
    Mannequin Author

    troels mannequin commented Jun 2, 2004

    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>

    @troels
    Copy link
    Mannequin Author

    troels mannequin commented Jun 8, 2004

    Logged In: YES
    user_id=32863

    Here is the fixed patch. It compiles and passes the
    regression test correctly on Windows 2003 Server.

    @troels
    Copy link
    Mannequin Author

    troels mannequin commented Jun 9, 2004

    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.

    @amauryfa
    Copy link
    Member

    amauryfa commented Dec 5, 2008

    A similar patch was applied 4 years ago, in r36739.

    @amauryfa amauryfa closed this as completed Dec 5, 2008
    @amauryfa amauryfa closed this as completed Dec 5, 2008
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant