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

gh-93821: Fix bug that accepting a socket connection and ERROR_NETNAME_DELETED occurs causes serving socket to be closed #124032

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

StanHatko
Copy link

@StanHatko StanHatko commented Sep 13, 2024

Fixes issue #93821, using patch suggested by fercod in that thread. I tested that patch and found it worked properly on a Windows system, given the MWE at the top of the thread. I made a small change as I think accessing winerror within the exception handler could cause another exception on Linux and other systems without the winerror member of OSError.

I still want to do a bit more testing with Linux and Windows systems. It passed various default tests I ran (on a Linux computer) but we'd need to test with the relevant exceptions actually occurring in those spots to make sure it fully works everywhere. I hope to do that over the next few days.

…ETED occurs, leads this into a closing of the serving socket

This is done with the patches described by fercod in the GitHub thread python#93821.
These patches were successfully tested by me and worked properly.
The error propagates properly without closing the original socket and without causing the server to hang.
Copy link

cpython-cla-bot bot commented Sep 13, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Sep 13, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

No need for checking winerror present as windows_events.py only imported on Windows (with check near top).

Make comment more clear as to purpose of this patch.
@bedevere-app
Copy link

bedevere-app bot commented Sep 13, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanHatko
Copy link
Author

Second edit was not necessary since windows_events.py is always windows-only, line 5:

if sys.platform != 'win32':  # pragma: no cover
    raise ImportError('win32 only')

I'll revert that change to the patch.

@StanHatko
Copy link
Author

It seems the patch works, I'll just need to do a test on a Windows computer with the dev Python from the main branch to be sure. Once that's done I'll add the blurb NEWS entry and will mark it for review so it can be merged into Python.

@StanHatko
Copy link
Author

I did some testing with the new version and it was working properly for me, it fixed the bug #93821. Is the blurb now the only thing missing, or would you like any other changes made before accepting this pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant