[issue9550] BufferedReader may issue additional read, may cause hang when backed by blocking socket

2010-08-11 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

The original patch wasn't good for all cases. I corrected it, added some tests 
and committed in r83944 (py3k), r83945 (3.1) and r83946 (2.7). Thank you!

--
resolution:  -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
versions: +Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9550] BufferedReader may issue additional read, may cause hang when backed by blocking socket

2010-08-09 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Thanks for caring about such issues. This would also need unit tests and 
test_io.py (and perhaps a similar change in _pyio.py, although the buffering 
logic there is different and may not exhibit the issue).

--
stage:  -> needs patch
versions: +Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9550] BufferedReader may issue additional read, may cause hang when backed by blocking socket

2010-08-09 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9550] BufferedReader may issue additional read, may cause hang when backed by blocking socket

2010-08-09 Thread Jason V. Miller

New submission from Jason V. Miller :

While reading, BufferedReader can cause an additional read() to the underlying 
I/O object after the entire upper-layer byte count has been satisfied. This is 
unnecessary and troublesome in some cases.

In the event that the BufferedReader sits on top of a blocking socket (see the 
included test case,) certain network protocols (HTTP) can cause the server to 
hang in recv/recvfrom trying to read more data than will be available, causing 
a hang. I first ran into this issue running bottle on top of the core Python 
wsgi server.

It looks as though this may be present in 2.x as well, however an associate of 
mine wasn't able to trigger the issue in 2.x (even after implementing the 
makefile() code from 3.x)

To run the test case, start the server and then run the client against it.

bufio.py server
bufio.py client

I successfully patched this issue locally with the following:

---
Modules/_io/bufferedio.c:

self->pos = 0;
self->raw_pos = 0;
self->read_end = 0;

+   if ( remaining == 0 )
+   return res;
+

while (self->read_end < self->buffer_size) {
---

Which aborts execution of the second loop in the event that the last 
block-sized read satisfied the upper layer call exactly.

--
components: IO
files: bufio.py
messages: 113489
nosy: jvmiller
priority: normal
severity: normal
status: open
title: BufferedReader may issue additional read, may cause hang when backed by 
blocking socket
type: behavior
versions: Python 3.1
Added file: http://bugs.python.org/file18459/bufio.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com