[issue12498] asyncore.dispatcher_with_send, disconnection problem + miss-conception

Charles-François Natali report at bugs.python.org
Thu Nov 3 18:56:12 CET 2011


Charles-François Natali <neologix at free.fr> added the comment:

> The reason is that when TestHandler closes the connection after 
> writing the output buffer, the client receives a POLLHUP which 
> prevents it to receive the data since POLLHUP is triggering a call to 
> handle_close.

Yes, that's the problem it noticed in http://bugs.python.org/issue12498#msg146645 :
"""
(Note that the current code is probably broken: when POLLHUP is
received, this likely means that the remote end has shutdown the
connection, but there might still be some data in the input socket
buffer. I'll try to dig a little...).
"""

I think the best would be to not handle POLLHUP events while POLLIN is set, so that the handlers can have a chance to drain the input socket buffer.
But it's a separate issue, could you create a new one?
You may also add a patch (in the same issue) to remove the useless setting of input flags to poll():
"""
        if flags:
            # Only check for exceptions if object was either readable
            # or writable.
            flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL
            pollster.register(fd, flags)
"""

POLLERR, POLLHUP and POLLNVAL don't make sense when passed as input to poll() (they're set automatically in the output revents).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12498>
_______________________________________


More information about the Python-bugs-list mailing list