diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-28 23:36:51 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-28 23:36:51 (GMT) |
commit | fa73779b0a54211e99bd1e76511f30352c7055e9 (patch) | |
tree | 0abf1f81f382ddd5771db6b49d798e2a27d1eeaa /Lib/asyncio | |
parent | f07801bb17f8089dc8b8a4d2beafba7c497af900 (diff) | |
download | cpython-fa73779b0a54211e99bd1e76511f30352c7055e9.zip cpython-fa73779b0a54211e99bd1e76511f30352c7055e9.tar.gz cpython-fa73779b0a54211e99bd1e76511f30352c7055e9.tar.bz2 |
asyncio: Fix _SelectorSocketTransport constructor
Only start reading when connection_made() has been called:
protocol.data_received() must not be called before protocol.connection_made().
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/selector_events.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index 42d88f5..f499629 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -578,8 +578,10 @@ class _SelectorSocketTransport(_SelectorTransport): self._eof = False self._paused = False - self._loop.add_reader(self._sock_fd, self._read_ready) self._loop.call_soon(self._protocol.connection_made, self) + # only start reading when connection_made() has been called + self._loop.call_soon(self._loop.add_reader, + self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(waiter._set_result_unless_cancelled, None) |