mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibTLS: Don't close the underlying socket on EOF
This commit is contained in:
parent
e780ee2832
commit
d3ea0818f3
Notes:
sideshowbarker
2024-07-18 03:39:54 +09:00
Author: https://github.com/alimpfard
Commit: d3ea0818f3
Pull-request: https://github.com/SerenityOS/serenity/pull/10103
Reviewed-by: https://github.com/awesomekling
1 changed files with 12 additions and 5 deletions
|
@ -202,13 +202,24 @@ bool TLSv12::check_connection_state(bool read)
|
|||
if (m_context.connection_finished)
|
||||
return false;
|
||||
|
||||
if (!Core::Socket::is_open() || !Core::Socket::is_connected() || Core::Socket::eof()) {
|
||||
if (!Core::Socket::is_open() || !Core::Socket::is_connected()) {
|
||||
// an abrupt closure (the server is a jerk)
|
||||
dbgln_if(TLS_DEBUG, "Socket not open, assuming abrupt closure");
|
||||
m_context.connection_finished = true;
|
||||
m_context.connection_status = ConnectionStatus::Disconnected;
|
||||
Core::Socket::close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (read && Core::Socket::eof()) {
|
||||
if (m_context.application_buffer.size() == 0 && m_context.connection_status != ConnectionStatus::Disconnected) {
|
||||
m_context.has_invoked_finish_or_error_callback = true;
|
||||
if (on_tls_finished)
|
||||
on_tls_finished();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_context.critical_error) {
|
||||
dbgln_if(TLS_DEBUG, "CRITICAL ERROR {} :(", m_context.critical_error);
|
||||
|
||||
|
@ -227,12 +238,8 @@ bool TLSv12::check_connection_state(bool read)
|
|||
dbgln_if(TLS_DEBUG, "connection closed without finishing data transfer, {} bytes still in buffer and {} bytes in application buffer",
|
||||
m_context.tls_buffer.size(),
|
||||
m_context.application_buffer.size());
|
||||
} else {
|
||||
m_context.connection_finished = true;
|
||||
dbgln_if(TLS_DEBUG, "FINISHED");
|
||||
}
|
||||
if (!m_context.application_buffer.size()) {
|
||||
m_context.connection_status = ConnectionStatus::Disconnected;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue