Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes made to the SSL protocol implementation:
EOF
If the peer shuts down its writing end of the TCP connection (
transport.write_eof()
orsocket.shutdown(SHUT_WR)
) without sending a graceful SSLCLOSE NOTIFY
(ssl_sock.unwrap()
), we will now close the connection immediately, discard any data in the send buffer.eof_received()
will be called in asyncio, but uvloop won't do so after this PR.connection_lost()
will be called with parameterNone
in asyncio. Q: should we use put aConnectionResetError
instead?Refs RFC 8446, Section 6.1:
In asyncio,
eof_received()
should be treated as a sign of "the peer's pending data is reliably delivered". But in case we received an EOF on the TCP connection, we don't know if the peer has flushed all the pending data or not, so we shouldn't calleof_received()
on the SSL level. On the other hand, as many software is sending TCP EOF beforeCLOSE_NOTIFY
, we don't want to be too picky to failconnection_lost()
with an exception. So I think the proposed behavior is appropriate.Clean Shutdown
The shutdown process is now refactored to be more strict to follow the API.
After
transport.close()
is called:connection_lost()
.data_received()
,get_buffer()
,buffer_updated()
,pause_writing()
,resume_writing()
will ever be called again. This means application data received aftertransport.close()
will be discarded silently.pause_reading()
orresume_reading()
has no effect - the shutdown process will procceed unaffected.write_eof()
in addition totransport.close()
to receive trailing data during the shutdown process.Other Fixes
_call_soon_handle()
internally when possible._handshake_timeout_handle
correctly.CLOSE NOTIFY
is sent when the peer's TCP receiving buffer is full.