Visitar URL original
apply review · RustPython/RustPython@81685b2 · GitHub
Skip to content

Commit 81685b2

Browse files
committed
apply review
1 parent 6ffc617 commit 81685b2

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎crates/stdlib/src/openssl.rs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,10 +2851,18 @@ mod _ssl {
28512851
}
28522852
// Wait briefly for peer's close_notify before retrying
28532853
match socket_stream.select(SslNeeds::Read, &deadline) {
2854-
SelectRet::TimedOut => break, // Timeout waiting for peer
2855-
SelectRet::Closed => break, // Socket closed
2854+
SelectRet::TimedOut => {
2855+
return Err(vm.new_exception_msg(
2856+
vm.ctx.exceptions.timeout_error.to_owned(),
2857+
"The read operation timed out".to_owned(),
2858+
));
2859+
}
2860+
SelectRet::Closed => {
2861+
return Err(socket_closed_error(vm));
2862+
}
28562863
SelectRet::Nonblocking => {
2857-
// Non-blocking, just continue
2864+
// Non-blocking socket: return SSLWantReadError
2865+
return Err(create_ssl_want_read_error(vm).upcast());
28582866
}
28592867
SelectRet::Ok => {
28602868
// Data available, continue to retry

‎crates/stdlib/src/ssl.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4124,6 +4124,9 @@ mod _ssl {
41244124
// Non-blocking: return immediately after sending close_notify.
41254125
// Don't wait for peer's close_notify to avoid blocking.
41264126
drop(conn_guard);
4127+
// Best-effort flush; WouldBlock is expected in non-blocking mode.
4128+
// Other errors indicate close_notify may not have been sent,
4129+
// but we still complete shutdown to avoid inconsistent state.
41274130
let _ = self.flush_pending_tls_output(vm, None);
41284131
*self.shutdown_state.lock() = ShutdownState::Completed;
41294132
*self.connection.lock() = None;

0 commit comments

Comments
 (0)