summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-05-19 22:35:19 +0430
committerAndreas Kling <kling@serenityos.org>2020-05-20 08:30:51 +0200
commitf9cffda0e09470c41afad6da1dd8ac75ccde068f (patch)
tree1407aa3127cb08edfbf63ee2bb0af3474be366fc /Libraries
parentb69abb3626550d1d781e5e15ff20d0007ed5b62c (diff)
downloadserenity-f9cffda0e09470c41afad6da1dd8ac75ccde068f.zip
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.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibTLS/Record.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Libraries/LibTLS/Record.cpp b/Libraries/LibTLS/Record.cpp
index 423411cb73..1e43c0ceda 100644
--- a/Libraries/LibTLS/Record.cpp
+++ b/Libraries/LibTLS/Record.cpp
@@ -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;
+ }
}
}