dtls: try to flush rx queue at reception

give a chance to rx queue to immediatly push packets to application
when packet is received. This reduces a bit the latency of packet
handling.

Change-Id: I7c09d91ab505e9e65ebbb990f1d155b3d639e024
This commit is contained in:
Guillaume Roguez
2017-05-15 15:24:01 -04:00
parent 7bf85fdb3a
commit f62dccacb3

View File

@ -922,10 +922,15 @@ TlsSession::handleDataPacket(std::vector<uint8_t>&& buf, uint64_t pkt_seq)
RING_WARN("[dtls] OOO pkt: 0x%lx", pkt_seq);
}
std::lock_guard<std::mutex> lk {reorderBufMutex_};
if (reorderBuffer_.empty())
lastReadTime_ = clock::now();
reorderBuffer_.emplace(pkt_seq, std::move(buf));
{
std::lock_guard<std::mutex> lk {reorderBufMutex_};
if (reorderBuffer_.empty())
lastReadTime_ = clock::now();
reorderBuffer_.emplace(pkt_seq, std::move(buf));
}
// Try to flush right now as a new packet is available
flushRxQueue();
}
///
@ -972,7 +977,7 @@ TlsSession::flushRxQueue()
gapOffset_ = std::max(gapOffset_, next_offset);
lastReadTime_ = clock::now();
RING_DBG("[dtls] %lu pushed since 0x%lx", gapOffset_ - first_offset, first_offset);
RING_DBG("[dtls] push 0x%lx (%lu pkt)", first_offset, gapOffset_ - first_offset);
}
TlsSessionState