Skip to content

Commit

Permalink
Clean up compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ZXGuesser committed Mar 18, 2024
1 parent 77a0569 commit f6b2fce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions packetServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,34 @@ void PacketServer::SendField(std::vector<std::vector<uint8_t>> FrameBuffer)
}
}

int sock;
int ret;
for (i = 0; i < MAXCLIENTS; i++)
{
if (_mtx[i].try_lock()) // skip this socket if unable to lock mutex as it's in the process of being closed
{
if (_clientSocks[i] >= 0)
sock = _clientSocks[i];
if (sock >= 0)
{
ret = send(_clientSocks[i], (char*)RawFrameBuffer.data(), RawFrameBuffer.size(), 0);
// should do something here if send ever fails like close the socket
ret = send(sock, (char*)RawFrameBuffer.data(), RawFrameBuffer.size(), 0);
if (ret != RawFrameBuffer.size())
{
#ifdef WIN32
int e = WSAGetLastError();
#else
int e = errno;
#endif

std::cerr << "[PacketServer::SendField] send() failed. Closing socket " << sock << " send error " << e << std::endl;

_clientSocks[i] = -1; /* free slot */

#ifdef WIN32
closesocket(sock);
#else
close(sock);
#endif
}
}
_mtx[i].unlock();
}
Expand Down
2 changes: 1 addition & 1 deletion pagelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ TTXPageStream* PageList::PrevPage()

if (_iter==_pageList[_iterMag].begin()) // beginning of mag?
{
if (_iterMag<=0)
if (_iterMag>0)
{
_iterMag--; // previous mag
_iter=_pageList[_iterMag].end();
Expand Down

0 comments on commit f6b2fce

Please sign in to comment.