mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #9550: a BufferedReader could issue an additional read when the
original read request had been satisfied, which can block indefinitely when the underlying raw IO channel is e.g. a socket. Report and original patch by Jason V. Miller.
This commit is contained in:
parent
5ea3d93708
commit
32cfedeb1c
4 changed files with 34 additions and 1 deletions
|
@ -1383,7 +1383,10 @@ _bufferedreader_read_generic(buffered *self, Py_ssize_t n)
|
|||
self->pos = 0;
|
||||
self->raw_pos = 0;
|
||||
self->read_end = 0;
|
||||
while (self->read_end < self->buffer_size) {
|
||||
/* NOTE: when the read is satisfied, we avoid issuing any additional
|
||||
reads, which could block indefinitely (e.g. on a socket).
|
||||
See issue #9550. */
|
||||
while (remaining > 0 && self->read_end < self->buffer_size) {
|
||||
Py_ssize_t r = _bufferedreader_fill_buffer(self);
|
||||
if (r == -1)
|
||||
goto error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue