• Victor Stinner's avatar
    asyncio, Tulip issue 205: Fix a race condition in BaseSelectorEventLoop.sock_connect() · d5aeccf9
    Victor Stinner yazdı
    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.
    d5aeccf9
Adı
Son kayıt (commit)
Son güncelleme
..
__init__.py Loading commit data...
base_events.py Loading commit data...
base_subprocess.py Loading commit data...
constants.py Loading commit data...
coroutines.py Loading commit data...
events.py Loading commit data...
futures.py Loading commit data...
locks.py Loading commit data...
log.py Loading commit data...
proactor_events.py Loading commit data...
protocols.py Loading commit data...
queues.py Loading commit data...
selector_events.py Loading commit data...
streams.py Loading commit data...
subprocess.py Loading commit data...
tasks.py Loading commit data...
test_utils.py Loading commit data...
transports.py Loading commit data...
unix_events.py Loading commit data...
windows_events.py Loading commit data...
windows_utils.py Loading commit data...