-
-
Notifications
You must be signed in to change notification settings - Fork 99
Fix race conditions and improve robustness during socket I/O #779
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
base: main
Are you sure you want to change the base?
Conversation
887399d
to
4f1662e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #779 +/- ##
==========================================
- Coverage 79.24% 79.16% -0.08%
==========================================
Files 29 29
Lines 4201 4315 +114
Branches 538 550 +12
==========================================
+ Hits 3329 3416 +87
- Misses 728 755 +27
Partials 144 144 |
4f1662e
to
4833dac
Compare
048d898
to
f0471ca
Compare
|
||
class MockSocket: | ||
"""A mock socket.""" | ||
"""A mock socket for emulating buffered I/O.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's extract this into a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand. The only thing modified here was the docstring. This was to distinguish MockSocket
which was already there from MockRawSocket
which I am adding. Originally, I added the latter in the same file but had to move to test_errors.py because the linter said I had too many modules in test_makefile.py.
9a6bb9f
to
2e35bcb
Compare
90d7cb6
to
03ecb25
Compare
Fixes to make socket I/O more resilient during connection teardown. 1. BufferedWriter's write(): Added error handling to ignore common socket errors (e.g., ECONNRESET, EPIPE, ENOTCONN, EBADF) that occur when the underlying connection has been unexpectedly closed by the client or OS. This prevents a crash when attempting to write to a defunct socket. 2. BufferedWriters's close(): Made idempotent, allowing safe repeated calls without raising exceptions. 3. Needed to add explicit handling of WINDOWS environments as these are seen to throw Windows specific WSAENOTSOCK errors. Includes new unit tests to cover the idempotency and graceful handling of already closed underlying buffers.
03ecb25
to
9e1e189
Compare
Fixed race conditions to make socket I/O more resilient during connection teardown.
write()
: Added error handling to ignore common socket errors (e.g.,ECONNRESET
,EPIPE
,ENOTCONN
,EBADF
) that occur when the underlying connection has been unexpectedly closed by the client or OS. This prevents a crash when attempting to write to a defunct socket.close()
: Made idempotent, allowing safe repeated calls without raising exceptions.WSAENOTSOCK
errors.Includes new unit tests to cover the idempotency and graceful handling of already closed underlying buffers.
This change is