Commit c7e53c07 authored by Andreas Schmidt's avatar Andreas Schmidt

Socket interrupt and termination.

parent ba373eae
Pipeline #2654 passed with stages
in 1 minute and 25 seconds
......@@ -318,14 +318,15 @@ int PrrtSocket_interrupt(PrrtSocket *s) {
void **res = NULL;
if (s->sendDataThread != 0) {
check(pthread_join(s->sendDataThread, res) == 0, "Join failed.");
check(pthread_cancel(s->sendDataThread) == EXIT_SUCCESS, "Cancel failed.");
check(pthread_join(s->sendDataThread, res) == EXIT_SUCCESS, "Join failed.");
pthread_attr_destroy(s->sendDataThreadAttr);
s->sendDataThread = 0;
}
if (s->receiveDataThread != 0) {
pthread_cancel(s->receiveDataThread);
check(pthread_join(s->receiveDataThread, res) == 0, "Join failed.");
check(pthread_cancel(s->receiveDataThread) == EXIT_SUCCESS, "Cancel failed.");
check(pthread_join(s->receiveDataThread, res) == EXIT_SUCCESS, "Join failed.");
pthread_attr_destroy(s->receiveDataThreadAttr);
s->receiveDataThread = 0;
}
......@@ -348,31 +349,32 @@ int PrrtSocket_close(PrrtSocket *s) {
}
if (s->repairBlockStore != NULL) {
PrrtRepairBlockStore_destroy(s->repairBlockStore);
check(PrrtRepairBlockStore_destroy(s->repairBlockStore), "Destroy failed.");
s->repairBlockStore = NULL;
}
if (s->receiver != NULL) {
PrrtReceiver_destroy(s->receiver);
check(PrrtReceiver_destroy(s->receiver), "Destroy failed.");
s->receiver = NULL;
}
if (s->sendDataQueue != NULL) {
Pipe_destroy(s->sendDataQueue);
check(Pipe_destroy(s->sendDataQueue), "Destroy failed.");
s->sendDataQueue = NULL;
}
if (s->dataReceptionTable != NULL) {
PrrtReceptionTable_destroy(s->dataReceptionTable);
check(PrrtReceptionTable_destroy(s->dataReceptionTable), "Destroy failed.");
s->dataReceptionTable = NULL;
}
if (s->redundancyReceptionTable != NULL) {
PrrtReceptionTable_destroy(s->redundancyReceptionTable);
check(PrrtReceptionTable_destroy(s->redundancyReceptionTable), "Destroy failed.");
s->redundancyReceptionTable = NULL;
}
if (s->packetDeliveryStore != NULL) {
PrrtPacketDeliveryStore_destroy(s->packetDeliveryStore);
check(PrrtPacketDeliveryStore_destroy(s->packetDeliveryStore), "Destroy failed.");
s->packetDeliveryStore = NULL;
}
......@@ -388,6 +390,7 @@ int PrrtSocket_close(PrrtSocket *s) {
if (s->address != NULL) {
free(s->address);
s->address = NULL;
}
if (s->applicationConstraints != NULL) {
......
......@@ -29,7 +29,7 @@ Pipe *Pipe_create(void) {
abort();
}
void Pipe_destroy(Pipe *self) {
bool Pipe_destroy(Pipe *self) {
void* node = Pipe_poll(self);
while (node != 0) {
free(node);
......@@ -40,6 +40,7 @@ void Pipe_destroy(Pipe *self) {
self->head = NULL;
}
free(self);
return true;
}
static void pipe_wait_for(atomic_int *var) {
......
......@@ -19,7 +19,7 @@ typedef struct pipe {
Pipe *Pipe_create(void);
void Pipe_destroy(Pipe *);
bool Pipe_destroy(Pipe *);
void Pipe_push(Pipe *, ListNode *);
......
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