Any chance you could modify the source a bit to add more logging, so that we know where exactly the problem happens?
I'm guessing it's somewhere in the cSocketThreads::cSocketThread::Execute() method. So replace that method (cSocketThreads.cpp, line ~500) with this code:
This should provide a more detailed log, so paste it here.
I'm guessing it's somewhere in the cSocketThreads::cSocketThread::Execute() method. So replace that method (cSocketThreads.cpp, line ~500) with this code:
Code:
void cSocketThreads::cSocketThread::Execute(void)
{
// Connect the "client" part of the Control socket:
LOG("Execute() start");
m_ControlSocket1 = cSocket::CreateSocket();
cSocket::SockAddr_In Addr;
Addr.Family = cSocket::ADDRESS_FAMILY_INTERNET;
Addr.Address = cSocket::INTERNET_ADDRESS_LOCALHOST();
Addr.Port = m_ControlSocket2.GetPort();
ASSERT(Addr.Port != 0); // We checked in the Start() method, but let's be sure
if (m_ControlSocket1.Connect(Addr) != 0)
{
LOGERROR("Cannot connect Control sockets for a cSocketThread (\"%s\"); continuing, but the server may be unreachable from now on.", Socket::GetLastErrorString().c_str());
m_ControlSocket2.CloseSocket();
return;
}
LOG("ControlSockets connected");
// The main thread loop:
while (!m_ShouldTerminate)
{
// Put all sockets into the Read set:
fd_set fdRead;
cSocket::xSocket Highest = m_ControlSocket1.GetSocket();
LOG("Preparing fdRead");
PrepareSet(&fdRead, Highest);
// Wait for the sockets:
LOG("select()ing fdRead");
if (select(Highest + 1, &fdRead, NULL, NULL, NULL) == -1)
{
LOG("select(R) call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;
}
LOG("Reading from sockets");
ReadFromSockets(&fdRead);
// Test sockets for writing:
LOG("Preparing fdWrite");
fd_set fdWrite;
Highest = m_ControlSocket1.GetSocket();
PrepareSet(&fdWrite, Highest);
timeval Timeout;
Timeout.tv_sec = 0;
Timeout.tv_usec = 0;
LOG("Selecting fdWrite");
if (select(Highest + 1, NULL, &fdWrite, NULL, &Timeout) == -1)
{
LOG("select(W) call failed in cSocketThread: \"%s\"", cSocket::GetLastErrorString().c_str());
continue;
}
LOG("Writing to sockets");
WriteToSockets(&fdWrite);
LOG("Removing closed sockets");
RemoveClosedSockets();
} // while (!mShouldTerminate)
}