Skip to content

SSLProtocol violates app Protocol state machine #246

Description

@jeremy-hiatt
  • 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions