From 37d42d27ad6bc05d99c64d24436cb865af43dbde Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 5 Mar 2022 17:46:11 +0100 Subject: [PATCH] Add missing shutdown/close --- src/utils/TcpReceiver.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/TcpReceiver.cpp b/src/utils/TcpReceiver.cpp index 0307bd6..3e3c792 100644 --- a/src/utils/TcpReceiver.cpp +++ b/src/utils/TcpReceiver.cpp @@ -39,6 +39,8 @@ TcpReceiver::~TcpReceiver() { if (serverSocket >= 0) { shutdown(serverSocket, SHUT_RDWR); + close(serverSocket); + serverSocket = -1; } } @@ -62,12 +64,16 @@ void TcpReceiver::executeThread() { socklen_t len; int32_t ret; if ((ret = bind(serverSocket, (struct sockaddr *) &bindAddress, 16)) < 0) { + shutdown(serverSocket, SHUT_RDWR); close(serverSocket); + serverSocket = -1; return; } if ((ret = listen(serverSocket, 1)) < 0) { + shutdown(serverSocket, SHUT_RDWR); close(serverSocket); + serverSocket = -1; return; } @@ -94,7 +100,9 @@ void TcpReceiver::executeThread() { } } + shutdown(serverSocket, SHUT_RDWR); close(serverSocket); + serverSocket = -1; } int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {