Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
flush pending
  • Loading branch information
youknowone committed Jan 4, 2026
commit 23436d4fc5552fa57f09654499cf055d950b0318
10 changes: 10 additions & 0 deletions crates/stdlib/src/ssl/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,16 @@ pub(super) fn ssl_read(
None // BIO mode has no deadline
};

// CRITICAL: Flush any pending TLS output before reading
// This ensures data from previous write() calls is sent before we wait for response.
// Without this, write() may leave data in pending_tls_output (if socket buffer was full),
// and read() would timeout waiting for a response that the server never received.
if !is_bio {
socket
.flush_pending_tls_output(vm, deadline)
.map_err(SslError::Py)?;
}

// Loop to handle TLS records and post-handshake messages
// Matches SSL_read behavior which loops until data is available
// - CPython uses OpenSSL's SSL_read which loops on SSL_ERROR_WANT_READ/WANT_WRITE
Expand Down
Loading