Commit 67740212 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Socket only has a single receiver.

parent dd4e7895
Pipeline #1652 failed with stages
in 1 minute and 33 seconds
......@@ -106,7 +106,7 @@ cdef extern from "proto/socket.h":
BPTreeNode* dataStore
List* receivers
PrrtReceiver* receiver
uint16_t packetsCount
uint16_t sequenceNumberSource
......
......@@ -91,25 +91,9 @@ static bool send_packet(PrrtSocket *sock_ptr, PrrtPacket *packet) {
default:;
}
uint32_t receiver_count = List_count(sock_ptr->receivers);
struct timespec **timestamps = calloc(receiver_count, sizeof(struct timespec *));
int i = 0;
// SENDING TO ALL RECEIVERS
LIST_FOREACH(sock_ptr->receivers, first, next, cur) {
PrrtReceiver *recv = cur->value;
timestamps[i] = calloc(sizeof(struct timespec), 1);
send_to_socket(sock_ptr, recv, buf, length, timestamps[i]);
i++;
usleep(1);
}
XlapTimeStampValue(sock_ptr, ts_data_packet, packet->sequenceNumber, ChannelTransmit, *timestamps[i-1]);
// TODO: Make less ugly.
for(int j = 0; j < receiver_count; j++) {
free(timestamps[j]);
}
free(timestamps);
struct timespec timestamp;
send_to_socket(sock_ptr, sock_ptr->receiver, buf, length, &timestamp);
XlapTimeStampValue(sock_ptr, ts_data_packet, packet->sequenceNumber, ChannelTransmit, timestamp);
switch (PrrtPacket_type(packet)) {
case PACKET_TYPE_DATA:
......
......@@ -19,7 +19,6 @@
#include "stores/forwardPacketTable.h"
#include "types/packetTimeout.h"
#include "socket.h"
#include "receiver.h"
PrrtSocket *PrrtSocket_create(const bool is_sender, prrtTimedelta_t target_delay_us) {
assert(sizeof(float) == 4);
......@@ -36,6 +35,7 @@ PrrtSocket *PrrtSocket_create(const bool is_sender, prrtTimedelta_t target_delay
PrrtClock_init(&s->clock);
s->isBound = false;
s->receiver = NULL;
s->codingParameters = PrrtCodingParams_create();
......@@ -69,8 +69,6 @@ PrrtSocket *PrrtSocket_create(const bool is_sender, prrtTimedelta_t target_delay
if (is_sender) {
s->sendDataQueue = Pipe_create();
s->receivers = List_create();
} else {
s->forwardPacketTable = PrrtForwardPacketTable_create();
s->repairBlockStore = PrrtRepairBlockStore_create();
......@@ -206,8 +204,10 @@ bool PrrtSocket_bind(PrrtSocket *s, const char *ipAddress, const uint16_t port)
}
int PrrtSocket_connect(PrrtSocket *s, const char *host, const uint16_t port) {
PrrtReceiver *recv = PrrtReceiver_create(host, port);
List_push(s->receivers, recv);
if(s->receiver != NULL) {
PrrtReceiver_destroy(s->receiver);
}
s->receiver = PrrtReceiver_create(host, port);
return 0;
}
......@@ -384,13 +384,8 @@ int PrrtSocket_close(PrrtSocket *s) {
s->repairBlockStore = NULL;
}
if (s->receivers != NULL) {
while (List_count(s->receivers) > 0) {
PrrtReceiver *recv = List_shift(s->receivers);
PrrtReceiver_destroy(recv);
}
List_destroy(s->receivers);
s->receivers = NULL;
if (s->receiver != NULL) {
PrrtReceiver_destroy(s->receiver);
}
if (s->sendDataQueue != NULL) {
......
......@@ -16,6 +16,7 @@
#include "stores/receiveDataQueue.h"
#include "clock.h"
#include "../xlap/xlap.h"
#include "receiver.h"
#ifndef SIOCSHWTSTAMP
# define SIOCSHWTSTAMP 0x89b0
......@@ -46,7 +47,7 @@ typedef struct prrtSocket {
PrrtForwardPacketTable *forwardPacketTable;
List *receivers;
PrrtReceiver* receiver;
atomic_bool closing;
......
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