Prevent socket write buffer from being cleared when prematurely#822
Open
cbbm142 wants to merge 4 commits into
Open
Prevent socket write buffer from being cleared when prematurely#822cbbm142 wants to merge 4 commits into
cbbm142 wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #822 +/- ##
==========================================
- Coverage 78.32% 78.24% -0.08%
==========================================
Files 41 41
Lines 4788 4809 +21
Branches 547 549 +2
==========================================
+ Hits 3750 3763 +13
- Misses 900 906 +6
- Partials 138 140 +2 |
5cd058a to
ebf303f
Compare
Add a check in cheroot.makefile.BufferedWriter._flush_unlocked to prevent clearing of the write buffer when raw.write() returns None due to a blocked stream. Also limits each write call to SOCK_WRITE_BLOCKSIZE bytes, which was defined but not previously used in this method.
Updated test to allow Flake8/pre-commit checks to pass successfully.
Updated allowlist to include buf, io, and RawIOBase
Added changelog entry for change cherrypy#822
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a check in cheroot.makefile.BufferedWriter._flush_unlocked to prevent clearing of the write buffer when raw.write() returns None due to a blocked stream. Also limits each write call to SOCK_WRITE_BLOCKSIZE bytes, which was defined but not previously used in this method.
❓ What kind of change does this PR introduce?
Prevent socket write buffer from being cleared when it is blocked
📋 What is the related issue number (starting with
#)Resolves #821
❓ What is the current behavior? (You can also link to an open issue here)
#821
❓ What is the new behavior (if this is a feature change)?
N/A
📋 Other information:
This bug is hard to reproduce and spot in production since there are no tracebacks or log messages associated with it. It happens because n can be None, and then
del self._write_buf[:n]becomesdel self._write_buf[:]which will clear everything left in the buffer.📋 Contribution checklist:
(If you're a first-timer, check out
this guide on making great pull requests)
the changes have been approved
and description in grammatically correct, complete sentences