diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-08-31 15:08:21 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-08-31 15:08:21 +0200 |
commit | de993bd9b68f1a1c2a3208e2024c94f99eb6cd05 (patch) | |
tree | ccbe623f58be09f2e834cce3b4ab86e07d135bb9 /Python/Python-ast.c | |
parent | 41c13ce50ad07847ffb609fcabdb25a07b897db4 (diff) | |
parent | d5aeccf9767c1619faa29e8ed61c93bde7bc5e3f (diff) | |
download | cpython-git-de993bd9b68f1a1c2a3208e2024c94f99eb6cd05.tar.gz |
(Merge 3.4) asyncio, Tulip issue 205: Fix a race condition in
BaseSelectorEventLoop.sock_connect()
There is a race condition in create_connection() used with wait_for() to have a
timeout. sock_connect() registers the file descriptor of the socket to be
notified of write event (if connect() raises BlockingIOError). When
create_connection() is cancelled with a TimeoutError, sock_connect() coroutine
gets the exception, but it doesn't unregister the file descriptor for write
event. create_connection() gets the TimeoutError and closes the socket.
If you call again create_connection(), the new socket will likely gets the same
file descriptor, which is still registered in the selector. When sock_connect()
calls add_writer(), it tries to modify the entry instead of creating a new one.
This issue was originally reported in the Trollius project, but the bug comes
from Tulip in fact (Trollius is based on Tulip):
https://bitbucket.org/enovance/trollius/issue/15/after-timeouterror-on-wait_for
This change fixes the race condition. It also makes sock_connect() more
reliable (and portable) is sock.connect() raises an InterruptedError.
Diffstat (limited to 'Python/Python-ast.c')
0 files changed, 0 insertions, 0 deletions