Commit ca82a6e9 authored by Andreas Schmidt's avatar Andreas Schmidt

Packets in deliveryStore also expire.

parent f37eff7b
Pipeline #2790 passed with stages
in 1 minute and 26 seconds
......@@ -465,9 +465,8 @@ PrrtCodingConfiguration *PrrtSocket_get_coding_parameters(PrrtSocket *s) {
bool PrrtSocket_cleanup(PrrtSocket *s) {
debug(DEBUG_CLEANUP, "PrrtSocket_cleanup");
if (s->packetTimeoutTable != NULL) {
List *expired_packets = PrrtPacketTimeoutTable_expire_packets(s->packetTimeoutTable,
PrrtClock_get_prrt_time_us(
&s->clock));
prrtTimestamp_t now = PrrtClock_get_current_time_us();
List *expired_packets = PrrtPacketTimeoutTable_expire_packets(s->packetTimeoutTable, now);
uint32_t expired_count = List_count(expired_packets);
debug(DEBUG_CLEANUP, "EXPIRED");
if (expired_count > 0) {
......@@ -498,6 +497,7 @@ bool PrrtSocket_cleanup(PrrtSocket *s) {
PrrtPacketTimeout *packetTimeout = (PrrtPacketTimeout *) List_shift(expired_packets);
PrrtPacketTimeout_destroy(packetTimeout);
}
PrrtPacketDeliveryStore_cleanup(s->packetDeliveryStore, now);
}
List_destroy(expired_packets);
}
......
......@@ -163,3 +163,19 @@ bool PrrtPacketDeliveryStore_insert(PrrtPacketDeliveryStore *store, PrrtPacket *
PERROR("Insert failed%s.", "");
return false;
}
void PrrtPacketDeliveryStore_cleanup(PrrtPacketDeliveryStore *store, prrtTimestamp_t now) {
List* packetList = List_create();
if (now >= TIMESTAMP_SPACE/2) {
BPTree_get_range(store->tree, packetList, now - TIMESTAMP_SPACE/2, now);
} else {
BPTree_get_range(store->tree, packetList, 0, now);
BPTree_get_range(store->tree, packetList, now + TIMESTAMP_SPACE/2, TIMESTAMP_SPACE);
}
while (List_count(packetList) > 0) {
PrrtPacket *block = List_shift(packetList);
store->tree = BPTree_delete(store->tree, block->sequenceNumber);
PrrtPacket_destroy(block);
}
List_destroy(packetList);
}
\ No newline at end of file
......@@ -25,6 +25,8 @@ PrrtPacket *PrrtPacketDeliveryStore_get_packet_timedwait(PrrtPacketDeliveryStore
bool PrrtPacketDeliveryStore_insert(PrrtPacketDeliveryStore *store, PrrtPacket *packet);
void PrrtPacketDeliveryStore_cleanup(PrrtPacketDeliveryStore *store, prrtTimestamp_t now);
void PrrtPacketDeliveryStore_interrupt(PrrtPacketDeliveryStore *store);
bool PrrtPacketDeliveryStore_destroy(PrrtPacketDeliveryStore *store);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment