Skip to content

Drain buffered TLS reads after TCP EOF - #795

Open
itisrmk wants to merge 1 commit into
MagicStack:masterfrom
itisrmk:devin/1795854045-drain-tls-before-tcp-eof
Open

itisrmk wants to merge 1 commit into
MagicStack:masterfrom
itisrmk:devin/1795854045-drain-tls-before-tcp-eof

Conversation

@itisrmk

@itisrmk itisrmk commented Nov 28, 2026

Copy link
Copy Markdown

Fixes #792.

When a TLS peer closes TCP while application reads are paused, keep the transport alive long enough to deliver buffered plaintext after reads resume. A bare TCP EOF still does not count as a TLS close_notify. The regression covers both ordinary and buffered protocols. The existing shutdown test now explicitly closes the client to preserve its check that an application close discards trailing data.

The regression previously failed with AssertionError: 0 != 20480. After rebuilding the extension, the TCP/SSL suite passes (118 tests, 21 skipped) on CPython 3.12/Linux.

AI disclosure: Devin drafted the patch and regression test.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL transport drops buffered data when peer closes TCP without close_notify while reading is paused

1 participant