You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With use_poll=True on linux, asyncore calls handle_write() after the
socket has been closed.
More specifically, it looks like asyncore dispatches handle_read() and
handle_close() events between the writable() test and the corresponding
handle_write() call. If handle_close() calls close(), as asyncore's
default implementation does, the subsequent handle_write() will fail and
generate an EBADF (bad file descriptor) exception. If handle_error()
also calls close(), as asyncore's default implementation does, this will
mean close() gets called twice on the same socket.
I am attaching example code which demonstrates the problem on Linux
2.6.24 using python 2.5.2, 2.5.3rc1, and 2.6. In one window, run
pollwritefail.py. In another window, establish a TCP connection to port
12345 and immediately close it without reading or writing. This can be
done from within the python interactive interpreter like this:
The output from pollwritefail.py will look like this:
writable() - asyncore asked if we have data to write
handle_read() - asyncore asked us to read
handle_close() - asyncore said the remote host closed connection
close() - we are closing our end of the connection
handle_write() - asyncore asked us to write
handle_error() - asyncore exception: (9, 'Bad file descriptor')
close() - we are closing our end of the connection
IMHO, two things need fixing here:
When writable() returns True, the next handler asyncore calls should
be handle_write(). Calling other handlers in between risks invalidating
the writable() return value.
After close(), asyncore should not call handle_write(), even if
writable() would return true.
This problem must have been solved at some point because this is what I get now on Linux by using python 2.7:
writable() - asyncore asked if we have data to write
handle_read() - asyncore asked us to read
handle_close() - asyncore said the remote host closed connection
close() - we are closing our end of the connection
handle_close() - asyncore said the remote host closed connection
close() - we are closing our end of the connection
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: