• 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
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
PCbuild Loading commit data...
Parser Loading commit data...
Python Loading commit data...
Tools Loading commit data...
.bzrignore Loading commit data...
.gitignore Loading commit data...
.hgeol Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
.hgtouch Loading commit data...
LICENSE Loading commit data...
Makefile.pre.in Loading commit data...
README Loading commit data...
config.guess Loading commit data...
config.sub Loading commit data...
configure Loading commit data...
configure.ac Loading commit data...
install-sh Loading commit data...
pyconfig.h.in Loading commit data...
setup.py Loading commit data...