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

Add checks. Simplify repairBlock insert.

parent d55b4652
......@@ -100,7 +100,7 @@ void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct sockadd
PrrtClock_update(sock_ptr->clock, dataTimestamp, payload->groupRTT_us);
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.");
......@@ -154,7 +154,6 @@ void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet)
PrrtBlock *block = PrrtRepairBlockStore_get_block(socket->repairBlockStore,
redundancyPayload->baseSequenceNumber);
if(block == NULL) {
// TODO: PROPER CREATION
PrrtCodingParams *cpar = PrrtCodingParams_create();
cpar->k = redundancyPayload->k;
cpar->n = redundancyPayload->n;
......@@ -162,8 +161,7 @@ void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet)
block = PrrtBlock_create(cpar, redundancyPayload->baseSequenceNumber);
PrrtCodingParams_destroy(cpar);
PrrtRepairBlockStore_insert(socket->repairBlockStore, redundancyPayload->baseSequenceNumber,
block);
PrrtRepairBlockStore_insert(socket->repairBlockStore, block);
}
retrieve_data_blocks(socket, redundancyPayload->baseSequenceNumber, block->codingParams.k, block);
......
......@@ -61,10 +61,10 @@ PrrtBlock *PrrtRepairBlockStore_get_block(PrrtRepairBlockStore *store, prrtSeque
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.");
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.");
return true;
error:
......
......@@ -17,7 +17,7 @@ bool PrrtRepairBlockStore_delete(PrrtRepairBlockStore *store, prrtSequenceNumber
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,
prrtSequenceNumber_t stop);
......
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