Commit 122166aa authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Data packets are now send right away.

parent e6a10895
......@@ -34,6 +34,7 @@ bool send_packet(PrrtSocket *sock_ptr, PrrtPacket *packet) {
memcpy((void *) &targetaddr.sin_addr, hp->h_addr_list[0], (size_t) hp->h_length);
ssize_t sendtoRes = sendto(sock_ptr->dataSocketFd, buf, length, 0, (struct sockaddr *) &targetaddr, sizeof(targetaddr));
usleep(1);
check(sendtoRes >= 0, "Sendto failed.")
}
......@@ -79,10 +80,15 @@ void * send_data_loop(void *ptr) {
PrrtPacket *packet = List_shift(sock_ptr->outQueue);
packet->seqno = sock_ptr->sequenceNumberSource++;
packet->index = (uint8_t) (packet->seqno - block->baseSequenceNumber);
PrrtPacket* packetToSend = PrrtPacket_copy(packet);
send_packet(sock_ptr, packetToSend);
PrrtBlock_insert_data_packet(block, packet);
if (PrrtBlock_encode_ready(block)) {
// TODO: redundancy should only be sent when necessary
if (PrrtBlock_encode_ready(block) && false) {
uint32_t j = 0;
PrrtBlock_encode(block, &sock_ptr->sequenceNumberRedundancy);
......@@ -92,18 +98,11 @@ void * send_data_loop(void *ptr) {
send_packet(sock_ptr, red_pkt);
}
uint32_t dataBlocks = List_count(block->dataPackets);
for (j = 0; j < dataBlocks; j++) {
PrrtPacket *data_pkt = PrrtBlock_get_first_data(block);
send_packet(sock_ptr, data_pkt);
}
PrrtBlock_destroy(block);
block = NULL;
}
pthread_mutex_unlock(&sock_ptr->outQueueFilledMutex);
usleep(1);
}
error:
......
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