1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

LibTLS: Do not defer flushing alert packets

There's a good chance the TLS socket instance will be deleted before the
deferred invocation fires, and there's no real reason to defer flushes
of alerts anyway as they are usually sent on errors.
Fixes #21800.
This commit is contained in:
Ali Mohammad Pur 2023-11-10 10:38:37 +03:30 committed by Andreas Kling
parent 7eda36bbf4
commit 32e6fd9715
2 changed files with 4 additions and 4 deletions

View file

@ -32,11 +32,11 @@ ByteBuffer TLSv12::build_alert(bool critical, u8 code)
void TLSv12::alert(AlertLevel level, AlertDescription code)
{
auto the_alert = build_alert(level == AlertLevel::FATAL, (u8)code);
write_packet(the_alert);
write_packet(the_alert, true);
MUST(flush());
}
void TLSv12::write_packet(ByteBuffer& packet)
void TLSv12::write_packet(ByteBuffer& packet, bool immediately)
{
auto schedule_or_perform_flush = [&](bool immediate) {
if (m_context.connection_status > ConnectionStatus::Disconnected) {
@ -61,7 +61,7 @@ void TLSv12::write_packet(ByteBuffer& packet)
// Toooooo bad, drop the record on the ground.
return;
}
schedule_or_perform_flush(false);
schedule_or_perform_flush(immediately);
}
void TLSv12::update_packet(ByteBuffer& packet)