- uvloop version: 0.12.2
- Python version: 3.5.4
- Platform: Mac OS X
- Can you reproduce the bug with
PYTHONASYNCIODEBUG in env?: Yes
Some instances of the Protocol class assume connection_lost() can only be called if connection_made() was called at some point. This does not appear to be explicitly guaranteed in the Python documentation, but the following comment strongly suggests that intent:
https://github.com/python/cpython/blob/master/Lib/asyncio/protocols.py#L84
An error raised during the handshake phase triggers a transition back to UNWRAPPED:
https://github.com/MagicStack/uvloop/blob/master/uvloop/sslproto.pyx#L504
Following this code path further, we see that it will force close the transport, which triggers a call back to SSLProtocol.connection_lost(). This is then forwarded onto the app's Protocol instance, even though connection_made() was never called.
Would it be appropriate to change the following guard to also exclude the UNWRAPPED state?
https://github.com/MagicStack/uvloop/blob/master/uvloop/sslproto.pyx#L337
Alternatively a boolean value could be used to track whether or not connection_made() has ever been called.
PYTHONASYNCIODEBUGin env?: YesSome instances of the
Protocolclass assumeconnection_lost()can only be called ifconnection_made()was called at some point. This does not appear to be explicitly guaranteed in the Python documentation, but the following comment strongly suggests that intent:https://github.com/python/cpython/blob/master/Lib/asyncio/protocols.py#L84
An error raised during the handshake phase triggers a transition back to
UNWRAPPED:https://github.com/MagicStack/uvloop/blob/master/uvloop/sslproto.pyx#L504
Following this code path further, we see that it will force close the transport, which triggers a call back to
SSLProtocol.connection_lost(). This is then forwarded onto the app'sProtocolinstance, even thoughconnection_made()was never called.Would it be appropriate to change the following guard to also exclude the
UNWRAPPEDstate?https://github.com/MagicStack/uvloop/blob/master/uvloop/sslproto.pyx#L337
Alternatively a boolean value could be used to track whether or not
connection_made()has ever been called.