diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-11 13:40:17 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-08-11 13:40:17 (GMT) |
commit | cb4f47c37704dec33135109d4b4d1ba5c31fc26f (patch) | |
tree | 7f5a391cf9d40b4c5663c5798859a252aafd65e2 /Modules/_io | |
parent | 0a1fa0e8b1fc888ae9978003c836e5a1953daef5 (diff) | |
download | cpython-cb4f47c37704dec33135109d4b4d1ba5c31fc26f.zip cpython-cb4f47c37704dec33135109d4b4d1ba5c31fc26f.tar.gz cpython-cb4f47c37704dec33135109d4b4d1ba5c31fc26f.tar.bz2 |
Merged revisions 83944 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83944 | antoine.pitrou | 2010-08-11 15:31:33 +0200 (mer., 11 août 2010) | 6 lines
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.
........
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/bufferedio.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 9a14d26..a68f8fe 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1388,7 +1388,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; |