Comment 6 for bug 824797

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 824797] Re: bzr serve doesn't drop idle/dead connections

On 13 September 2011 23:23, John A Meinel <email address hidden> wrote:
> select([c], [], [], 10.0) in terminal A and s.close() in terminal B will
> cause select to return before the timeout, and s.recv() to return the
> empty string. Is this a 'not-guaranteed-but-likely' behaviour?

You very likely want to select on c for errors as well as readability
(ie put it in the third list.)

If the remote end closes while select is waiting I think you are
guaranteed to get that behaviour - select will return communicating
"you can read" and then what you actually read is an EOF.

> AFAICT, even though the socket is set to blocking mode, sock.recv() is
returning an empty string, but select(sock) is not returning to indicate
the socket has bytes/is closed.

I wonder if this is a race where the eof arrives before you do the
select? I can't remember if that can actually happen.