Skip to content

Commit

Permalink
Ignore duplicative send_close_notify calls
Browse files Browse the repository at this point in the history
`tokio-rustls` has a test that accidentally does this twice.
Make this call idempotent.
  • Loading branch information
ctz committed May 17, 2024
1 parent ced64bc commit 7d4e809
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rustls/src/common_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,20 @@ impl CommonState {
err.into()
}

/// Queues a close_notify warning alert to be sent in the next
/// Queues a `close_notify` warning alert to be sent in the next
/// [`Connection::write_tls`] call. This informs the peer that the
/// connection is being closed.
///
/// Does nothing if any `close_notify` or fatal alert was already sent.
///
/// [`Connection::write_tls`]: crate::Connection::write_tls
pub fn send_close_notify(&mut self) {
if self.sent_fatal_alert {
return;
}
debug!("Sending warning alert {:?}", AlertDescription::CloseNotify);
self.send_warning_alert_no_log(AlertDescription::CloseNotify);
self.sent_fatal_alert = true;
}

pub(crate) fn eager_send_close_notify(
Expand Down

0 comments on commit 7d4e809

Please sign in to comment.