Skip to content

Commit

Permalink
Add missing shutdown/close
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed May 14, 2022
1 parent 3cf879d commit 37d42d2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/TcpReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ TcpReceiver::~TcpReceiver() {

if (serverSocket >= 0) {
shutdown(serverSocket, SHUT_RDWR);
close(serverSocket);
serverSocket = -1;
}
}

Expand All @@ -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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit 37d42d2

Please sign in to comment.