Commit 2447de48 authored by Andreas Schmidt's avatar Andreas Schmidt

Update locking.

parent ca82a6e9
Pipeline #2791 passed with stages
in 1 minute and 25 seconds
...@@ -122,6 +122,8 @@ PrrtPacket *PrrtPacketDeliveryStore_get_packet_wait(PrrtPacketDeliveryStore *sto ...@@ -122,6 +122,8 @@ PrrtPacket *PrrtPacketDeliveryStore_get_packet_wait(PrrtPacketDeliveryStore *sto
PrrtPacket *PrrtPacketDeliveryStore_get_packet(PrrtPacketDeliveryStore *store, prrtTimestamp_t start, prrtTimestamp_t stop) { PrrtPacket *PrrtPacketDeliveryStore_get_packet(PrrtPacketDeliveryStore *store, prrtTimestamp_t start, prrtTimestamp_t stop) {
PrrtPacket *packet = NULL; PrrtPacket *packet = NULL;
PrrtPacketDeliveryStore_cleanup(store, PrrtClock_get_current_time_us());
check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed."); check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed.");
if (start > stop) { if (start > stop) {
...@@ -165,6 +167,7 @@ bool PrrtPacketDeliveryStore_insert(PrrtPacketDeliveryStore *store, PrrtPacket * ...@@ -165,6 +167,7 @@ bool PrrtPacketDeliveryStore_insert(PrrtPacketDeliveryStore *store, PrrtPacket *
} }
void PrrtPacketDeliveryStore_cleanup(PrrtPacketDeliveryStore *store, prrtTimestamp_t now) { void PrrtPacketDeliveryStore_cleanup(PrrtPacketDeliveryStore *store, prrtTimestamp_t now) {
check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed.");
List* packetList = List_create(); List* packetList = List_create();
if (now >= TIMESTAMP_SPACE/2) { if (now >= TIMESTAMP_SPACE/2) {
BPTree_get_range(store->tree, packetList, now - TIMESTAMP_SPACE/2, now); BPTree_get_range(store->tree, packetList, now - TIMESTAMP_SPACE/2, now);
...@@ -178,4 +181,9 @@ void PrrtPacketDeliveryStore_cleanup(PrrtPacketDeliveryStore *store, prrtTimesta ...@@ -178,4 +181,9 @@ void PrrtPacketDeliveryStore_cleanup(PrrtPacketDeliveryStore *store, prrtTimesta
PrrtPacket_destroy(block); PrrtPacket_destroy(block);
} }
List_destroy(packetList); List_destroy(packetList);
check(pthread_mutex_unlock(&store->lock) == EXIT_SUCCESS, "Unlock failed.");
return;
error:
PERROR("PrrtPacketDeliveryStore_cleanup failed%s.", "");
} }
\ No newline at end of file
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