Staging
v0.5.1
https://github.com/python/cpython
Revision d5aeccf9767c1619faa29e8ed61c93bde7bc5e3f authored by Victor Stinner on 31 August 2014, 13:07:57 UTC, committed by Victor Stinner on 31 August 2014, 13:07:57 UTC
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.
1 parent 41f3c3f
History
Tip revision: d5aeccf9767c1619faa29e8ed61c93bde7bc5e3f authored by Victor Stinner on 31 August 2014, 13:07:57 UTC
asyncio, Tulip issue 205: Fix a race condition in BaseSelectorEventLoop.sock_connect()
Tip revision: d5aeccf
File Mode Size
RPM
ACKS -rw-r--r-- 21.6 KB
HISTORY -rw-r--r-- 1.1 MB
NEWS -rw-r--r-- 346.6 KB
Porting -rw-r--r-- 1.9 KB
README -rw-r--r-- 1.4 KB
README.AIX -rw-r--r-- 5.0 KB
README.coverity -rw-r--r-- 845 bytes
README.valgrind -rw-r--r-- 4.3 KB
SpecialBuilds.txt -rw-r--r-- 10.9 KB
coverity_model.c -rw-r--r-- 2.9 KB
gdbinit -rw-r--r-- 4.7 KB
indent.pro -rw-r--r-- 557 bytes
python-config.in -rw-r--r-- 2.0 KB
python-config.sh.in -rw-r--r-- 2.9 KB
python-wing3.wpr -rw-r--r-- 555 bytes
python-wing4.wpr -rw-r--r-- 835 bytes
python-wing5.wpr -rw-r--r-- 835 bytes
python.man -rw-r--r-- 13.5 KB
python.pc.in -rw-r--r-- 293 bytes
svnmap.txt -rw-r--r-- 4.1 MB
valgrind-python.supp -rw-r--r-- 8.2 KB
vgrindefs -rw-r--r-- 500 bytes

README

back to top