From 7490e0a7395e250b0e9756b3477565da6e0de8a5 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Thu, 13 May 2021 14:07:04 +0200 Subject: [PATCH] cleanup should be done now --- src/networking.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/networking.c b/src/networking.c index cb5f3ba..39e084a 100644 --- a/src/networking.c +++ b/src/networking.c @@ -690,6 +690,8 @@ void startRequestHandler(struct connection* connection) { pthread_t dataThreadId; void dataHandler(int signo) { + pthread_t self = pthread_self(); + debug("networking: data handler got called."); for(link_t* link = linked_first(&connectionList); link != NULL; link = linked_next(link)) { @@ -704,6 +706,15 @@ void dataHandler(int signo) { connection->inUse++; pthread_mutex_unlock(&(connection->lock)); + // if the connection is persistent there could be still + // unjoined threads -> join them + if (connection->threads.response != PTHREAD_NULL) { + stopThread(self, &(connection->threads.response), false); + } + if (connection->threads.encoder != PTHREAD_NULL) { + stopThread(self, &(connection->threads.encoder), false); + } + int tmp; char c; char buffer[BUFFER_LENGTH];