Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Race condition in BaseSelectorEventLoop.sock_connect() #205

Closed
GoogleCodeExporter opened this issue Apr 10, 2015 · 2 comments
Closed

Race condition in BaseSelectorEventLoop.sock_connect() #205

GoogleCodeExporter opened this issue Apr 10, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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

Original issue reported on code.google.com by victor.s...@gmail.com on 27 Aug 2014 at 9:29

@GoogleCodeExporter
Copy link
Author

Patch to fix the issue:
http://codereview.appspot.com/131370043

Original comment by victor.s...@gmail.com on 27 Aug 2014 at 9:37

@GoogleCodeExporter
Copy link
Author

Fix commited into Tulip (1cdaee714296), Python 3.4 (ad67f66a5f3c) and 3.5 
(28cbbe2ce104).

Original comment by victor.s...@gmail.com on 31 Aug 2014 at 1:20

  • Changed state: Fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant