Commit e73683dc authored by Marlene Böhmer's avatar Marlene Böhmer
Browse files

check timeout on delivery

parent 3063e8bc
Pipeline #4333 failed with stages
in 27667 minutes and 16 seconds
...@@ -99,22 +99,32 @@ PrrtPacket *PrrtPacketDeliveryStore_get_packet_timedwait(PrrtPacketDeliveryStore ...@@ -99,22 +99,32 @@ PrrtPacket *PrrtPacketDeliveryStore_get_packet_timedwait(PrrtPacketDeliveryStore
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;
bool timed_out;
check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed."); check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed.");
do {
if (start > stop) { timed_out = false;
packet = BPTree_get_first_in_range(store->tree, (BPTreeKey_t) start, TIMESTAMP_SPACE - 1);
if (packet == NULL) { if (start > stop) {
packet = BPTree_get_first_in_range(store->tree, 0, (BPTreeKey_t) stop); packet = BPTree_get_first_in_range(store->tree, (BPTreeKey_t) start, TIMESTAMP_SPACE - 1);
if (packet == NULL) {
packet = BPTree_get_first_in_range(store->tree, 0, (BPTreeKey_t) stop);
}
} else {
packet = BPTree_get_first_in_range(store->tree, (BPTreeKey_t) start, (BPTreeKey_t) stop);
} }
} else {
packet = BPTree_get_first_in_range(store->tree, (BPTreeKey_t) start, (BPTreeKey_t) stop); if(packet != NULL) {
} store->tree = BPTree_delete(store->tree, PrrtDataPacket_packet_timeout(packet));
prrtTimestamp_t now = PrrtClock_get_current_time_us();
if(packet != NULL) { if (PrrtTimestamp_cmp(now, PrrtDataPacket_packet_timeout(packet)) > 0) {
store->tree = BPTree_delete(store->tree, PrrtDataPacket_packet_timeout(packet)); timed_out = true;
} PrrtPacket_destroy(packet);
packet = NULL;
}
}
} while (timed_out);
check(pthread_mutex_unlock(&store->lock) == EXIT_SUCCESS, "Unlock failed."); check(pthread_mutex_unlock(&store->lock) == EXIT_SUCCESS, "Unlock failed.");
return packet; return packet;
......
Supports Markdown
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