1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibTLS: Don't close the underlying socket on EOF

This commit is contained in:
Ali Mohammad Pur 2021-09-19 03:39:37 +04:30 committed by Ali Mohammad Pur
parent e780ee2832
commit d3ea0818f3

View file

@ -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;
}
}