mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibTLS: Flush some packets as soon as more packets are written
This seems like a better compromise between throughput and latency, and it doesn't _really_ affect the performance, so let's just compromise.
This commit is contained in:
parent
b69abb3626
commit
f9cffda0e0
Notes:
sideshowbarker
2024-07-19 06:23:00 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/f9cffda0e09 Pull-request: https://github.com/SerenityOS/serenity/pull/2300
1 changed files with 14 additions and 3 deletions
|
@ -34,11 +34,22 @@ namespace TLS {
|
|||
void TLSv12::write_packet(ByteBuffer& packet)
|
||||
{
|
||||
m_context.tls_buffer.append(packet.data(), packet.size());
|
||||
if (!m_has_scheduled_write_flush && m_context.connection_status > ConnectionStatus::Disconnected) {
|
||||
if (m_context.connection_status > ConnectionStatus::Disconnected) {
|
||||
if (!m_has_scheduled_write_flush) {
|
||||
#ifdef TLS_DEBUG
|
||||
dbg() << "Scheduling write of " << m_context.tls_buffer.size();
|
||||
dbg() << "Scheduling write of " << m_context.tls_buffer.size();
|
||||
#endif
|
||||
deferred_invoke([this](auto&) { write_into_socket(); });
|
||||
deferred_invoke([this](auto&) { write_into_socket(); });
|
||||
m_has_scheduled_write_flush = true;
|
||||
} else {
|
||||
// multiple packet are available, let's flush some out
|
||||
#ifdef TLS_DEBUG
|
||||
dbg() << "Flushing scheduled write of " << m_context.tls_buffer.size();
|
||||
#endif
|
||||
write_into_socket();
|
||||
// the deferred invoke is still in place
|
||||
m_has_scheduled_write_flush = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue