Skip to content

Commit

Permalink
Add early return on UDP check if the socket is invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilemonn committed Jul 11, 2024
1 parent abf65e8 commit 5bc9564
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Environment-Test-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ COPY ./src ./src
COPY ./tests ./tests
COPY ./CMakeLists.txt ./CMakeLists.txt

# Do a fake copy to make sure it runs both stages
COPY --from=alpine /alpine/build/test/CppSocketLibraryTests /ubuntu/CppSocketLibraryTests

RUN ["cmake", "-B", "build", "."]

WORKDIR /ubuntu/build
RUN ["make", "all"]

WORKDIR /ubuntu/build/tests
RUN ["./CppSocketLibraryTests"]

# Do a fake copy to make sure it runs both stages
COPY --from=alpine /alpine/build/tests/CppSocketLibraryTests /ubuntu/CppSocketLibraryTests
6 changes: 5 additions & 1 deletion src/socket/UDPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,13 @@ namespace kt

int UDPSocket::pollSocket(SOCKET socket, const long& timeout) const
{
if (kt::isInvalidSocket(socket))
{
return -1;
}

timeval timeOutVal{};
int res = kt::pollSocket(socket, timeout, &timeOutVal);

return res;
}

Expand Down

0 comments on commit 5bc9564

Please sign in to comment.