Skip to content
Snippets Groups Projects
Commit 8038a295 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

tls: use ScheduledExecutor


Change-Id: I02ac07056e209b624d863c60d042ba48d52148b0
Reviewed-by: default avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>
parent 6aaf79f7
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@
#include "certstore.h"
#include "array_size.h"
#include "diffie-hellman.h"
#include "scheduled_executor.h"
#include <gnutls/gnutls.h>
#include <gnutls/dtls.h>
......@@ -249,6 +250,8 @@ public:
void process();
void cleanup();
ScheduledExecutor scheduler_;
// Path mtu discovery
std::array<int, 3> MTUS_;
int mtuProbe_;
......@@ -288,8 +291,6 @@ TlsSession::TlsSessionImpl::TlsSessionImpl(SocketType& transport,
});
}
Manager::instance().registerEventHandler((uintptr_t)this, [this]{ flushRxQueue(); });
// Run FSM into dedicated thread
thread_.start();
}
......@@ -299,7 +300,6 @@ TlsSession::TlsSessionImpl::~TlsSessionImpl()
thread_.join();
if (not transport_.isReliable())
transport_.setOnRecv(nullptr);
Manager::instance().unregisterEventHandler((uintptr_t)this);
}
const char*
......@@ -1032,6 +1032,7 @@ TlsSession::TlsSessionImpl::handleDataPacket(std::vector<ValueType>&& buf, uint6
// Try to flush right now as a new packet is available
flushRxQueue();
scheduler_.scheduleIn([this]{ flushRxQueue(); }, RX_OOO_TIMEOUT);
}
///
......@@ -1061,11 +1062,13 @@ TlsSession::TlsSessionImpl::flushRxQueue()
GuardedBoolSwap swap_flush_processing {flushProcessing_};
auto now = clock::now();
auto item = std::begin(reorderBuffer_);
auto next_offset = item->first;
// Wait for next continuous packet until timeout
if ((clock::now() - lastReadTime_) >= RX_OOO_TIMEOUT) {
if ((now - lastReadTime_) >= RX_OOO_TIMEOUT) {
// OOO packet timeout - consider waited packets as lost
if (auto lost = next_offset - gapOffset_)
RING_WARN("[TLS] %lu lost since 0x%lx", lost, gapOffset_);
......@@ -1091,7 +1094,7 @@ TlsSession::TlsSessionImpl::flushRxQueue()
}
gapOffset_ = std::max(gapOffset_, next_offset);
lastReadTime_ = clock::now();
lastReadTime_ = now;
}
TlsSessionState
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment