summaryrefslogtreecommitdiffstats
path: root/Modules/_io/bufferedio.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-11 13:38:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-11 13:38:10 (GMT)
commit00091cada63a756937a39d5e6967666301154b57 (patch)
treea184d24e4ed961701500dccb1560c753788af353 /Modules/_io/bufferedio.c
parent91ecc5667fa4c336087e1c3cd16aeedd916dde81 (diff)
downloadcpython-00091cada63a756937a39d5e6967666301154b57.zip
cpython-00091cada63a756937a39d5e6967666301154b57.tar.gz
cpython-00091cada63a756937a39d5e6967666301154b57.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/bufferedio.c')
-rw-r--r--Modules/_io/bufferedio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index c0c3acc..d8c1e65 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1379,7 +1379,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;