Skip to content
Snippets Groups Projects
Commit ebc6f6ef authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

dtls: fix race-condition during pkt flush


Remove a race-condition on packet reorder std::map
during its flush.
This caused application crashes.

Change-Id: I01ebf56f8cca141585f11c1090262d3b44f34544
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent db1a6e30
No related branches found
No related tags found
No related merge requests found
......@@ -962,16 +962,17 @@ TlsSession::flushRxQueue()
// Loop on offset-ordered received packet until a discontinuity in sequence number
while (item != std::end(reorderBuffer_) and item->first <= next_offset) {
auto pkt_offset = item->first;
auto& pkt = item->second;
auto pkt = std::move(item->second);
// Remove item before unlocking to not trash the item' relationship
next_offset = pkt_offset + 1;
item = reorderBuffer_.erase(item);
if (callbacks_.onRxData) {
lk.unlock();
callbacks_.onRxData(std::move(pkt));
lk.lock();
}
next_offset = pkt_offset + 1;
item = reorderBuffer_.erase(item);
}
gapOffset_ = std::max(gapOffset_, next_offset);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment