From 8801afaeb24cf1a51729af296c5fca864e7c3cb7 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Wed, 24 Aug 2022 11:25:16 -0400 Subject: [PATCH] Properly initialize and destroy the mutex --- src/HttpServer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/HttpServer.c b/src/HttpServer.c index b136cc2..b690345 100644 --- a/src/HttpServer.c +++ b/src/HttpServer.c @@ -119,6 +119,7 @@ HttpServerCreate(unsigned short port, unsigned int nThreads, unsigned int maxCon free(server); return NULL; } + pthread_mutex_init(&server->connQueueMutex, NULL); server->sd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); @@ -165,6 +166,8 @@ HttpServerFree(HttpServer * server) } close(server->sd); + QueueFree(server->connQueue); + pthread_mutex_destroy(&server->connQueueMutex); free(server); } @@ -186,7 +189,9 @@ HttpServerEventThread(void *args) struct sockaddr_storage addr; socklen_t addrLen = sizeof(addr); int connFd; - int pollResult = poll(pollFds, 1, 500); + int pollResult; + + pollResult = poll(pollFds, 1, 500); if (pollResult < 0) {