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
Raw File
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
.hgeol
[patterns]

# Non human-editable files are binary

**.dsp  = BIN
**.dsw  = BIN
**.mk   = BIN
**.sln  = BIN
**.vcproj  = BIN
**.vsprops = BIN

**.aif  = BIN
**.aifc = BIN
**.aiff = BIN
**.au   = BIN
**.bmp  = BIN
**.db   = BIN
**.exe  = BIN
**.icns = BIN
**.gif  = BIN
**.ico  = BIN
**.info = BIN
**.jpg  = BIN
**.pck  = BIN
**.png  = BIN
**.psd  = BIN
**.tar  = BIN
**.wav  = BIN
**.whl  = BIN
**.xar  = BIN
**.zip  = BIN

Lib/test/cjkencodings/* = BIN
Lib/test/decimaltestdata/*.decTest = BIN
Lib/test/sndhdrdata/sndhdr.* = BIN
Lib/test/test_email/data/msg_26.txt = BIN
Lib/test/xmltestdata/* = BIN

Lib/venv/scripts/nt/* = BIN

Lib/test/coding20731.py = BIN

# All other files (which presumably are human-editable) are "native".
# This must be the last rule!

** = native

[repository]
native = LF
back to top