Commit 744f9201 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Add checks. Simplify repairBlock insert.

parent d55b4652
...@@ -100,7 +100,7 @@ void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct sockadd ...@@ -100,7 +100,7 @@ void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct sockadd
PrrtClock_update(sock_ptr->clock, dataTimestamp, payload->groupRTT_us); PrrtClock_update(sock_ptr->clock, dataTimestamp, payload->groupRTT_us);
PrrtPacket *copiedPacket = PrrtPacket_copy(packet); PrrtPacket *copiedPacket = PrrtPacket_copy(packet);
PrrtPacketTimeoutTable_insert(sock_ptr->packetTimeoutTable, copiedPacket); check(PrrtPacketTimeoutTable_insert(sock_ptr->packetTimeoutTable, copiedPacket), "Could not insert data packet.");
check(send_feedback(sock_ptr, remote), "Sending feedback failed."); check(send_feedback(sock_ptr, remote), "Sending feedback failed.");
...@@ -154,7 +154,6 @@ void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) ...@@ -154,7 +154,6 @@ void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet)
PrrtBlock *block = PrrtRepairBlockStore_get_block(socket->repairBlockStore, PrrtBlock *block = PrrtRepairBlockStore_get_block(socket->repairBlockStore,
redundancyPayload->baseSequenceNumber); redundancyPayload->baseSequenceNumber);
if(block == NULL) { if(block == NULL) {
// TODO: PROPER CREATION
PrrtCodingParams *cpar = PrrtCodingParams_create(); PrrtCodingParams *cpar = PrrtCodingParams_create();
cpar->k = redundancyPayload->k; cpar->k = redundancyPayload->k;
cpar->n = redundancyPayload->n; cpar->n = redundancyPayload->n;
...@@ -162,8 +161,7 @@ void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) ...@@ -162,8 +161,7 @@ void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet)
block = PrrtBlock_create(cpar, redundancyPayload->baseSequenceNumber); block = PrrtBlock_create(cpar, redundancyPayload->baseSequenceNumber);
PrrtCodingParams_destroy(cpar); PrrtCodingParams_destroy(cpar);
PrrtRepairBlockStore_insert(socket->repairBlockStore, redundancyPayload->baseSequenceNumber, PrrtRepairBlockStore_insert(socket->repairBlockStore, block);
block);
} }
retrieve_data_blocks(socket, redundancyPayload->baseSequenceNumber, block->codingParams.k, block); retrieve_data_blocks(socket, redundancyPayload->baseSequenceNumber, block->codingParams.k, block);
......
...@@ -61,10 +61,10 @@ PrrtBlock *PrrtRepairBlockStore_get_block(PrrtRepairBlockStore *store, prrtSeque ...@@ -61,10 +61,10 @@ PrrtBlock *PrrtRepairBlockStore_get_block(PrrtRepairBlockStore *store, prrtSeque
return NULL; return NULL;
} }
bool PrrtRepairBlockStore_insert(PrrtRepairBlockStore *store, prrtSequenceNumber_t sequenceNumber, PrrtBlock *block) bool PrrtRepairBlockStore_insert(PrrtRepairBlockStore *store, PrrtBlock *block)
{ {
check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed."); check(pthread_mutex_lock(&store->lock) == EXIT_SUCCESS, "Lock failed.");
store->blockTree = BPTree_insert(store->blockTree, sequenceNumber, block); store->blockTree = BPTree_insert(store->blockTree, block->baseSequenceNumber, block);
check(pthread_mutex_unlock(&store->lock) == EXIT_SUCCESS, "Unlock failed."); check(pthread_mutex_unlock(&store->lock) == EXIT_SUCCESS, "Unlock failed.");
return true; return true;
error: error:
......
...@@ -17,7 +17,7 @@ bool PrrtRepairBlockStore_delete(PrrtRepairBlockStore *store, prrtSequenceNumber ...@@ -17,7 +17,7 @@ bool PrrtRepairBlockStore_delete(PrrtRepairBlockStore *store, prrtSequenceNumber
PrrtBlock *PrrtRepairBlockStore_get_block(PrrtRepairBlockStore *store, prrtSequenceNumber_t sequenceNumber); PrrtBlock *PrrtRepairBlockStore_get_block(PrrtRepairBlockStore *store, prrtSequenceNumber_t sequenceNumber);
bool PrrtRepairBlockStore_insert(PrrtRepairBlockStore *store, prrtSequenceNumber_t sequenceNumber, PrrtBlock *block); bool PrrtRepairBlockStore_insert(PrrtRepairBlockStore *store, PrrtBlock *block);
bool PrrtRepairBlockStore_expire_block_range(PrrtRepairBlockStore *store, prrtSequenceNumber_t start, bool PrrtRepairBlockStore_expire_block_range(PrrtRepairBlockStore *store, prrtSequenceNumber_t start,
prrtSequenceNumber_t stop); prrtSequenceNumber_t stop);
......
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