Skip to content

Commit 23436d4

Browse files
committed
flush pending
1 parent 8baade6 commit 23436d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/stdlib/src/ssl/compat.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,16 @@ pub(super) fn ssl_read(
14731473
None // BIO mode has no deadline
14741474
};
14751475

1476+
// CRITICAL: Flush any pending TLS output before reading
1477+
// This ensures data from previous write() calls is sent before we wait for response.
1478+
// Without this, write() may leave data in pending_tls_output (if socket buffer was full),
1479+
// and read() would timeout waiting for a response that the server never received.
1480+
if !is_bio {
1481+
socket
1482+
.flush_pending_tls_output(vm, deadline)
1483+
.map_err(SslError::Py)?;
1484+
}
1485+
14761486
// Loop to handle TLS records and post-handshake messages
14771487
// Matches SSL_read behavior which loops until data is available
14781488
// - CPython uses OpenSSL's SSL_read which loops on SSL_ERROR_WANT_READ/WANT_WRITE

0 commit comments

Comments
 (0)