fix: impl shutdown error handling

This commit is contained in:
izzy 2026-03-07 17:40:14 -05:00
parent 8a545f37f0
commit 0a8b0cb406
2 changed files with 51 additions and 24 deletions

View file

@ -151,8 +151,33 @@ ClientConnection::~ClientConnection()
void ClientConnection::tick() void ClientConnection::tick()
{ {
if (!done) connection->tick(); if (done) return;
connection->flush();
try
{
connection->tick();
connection->flush();
}
catch (const IOException &e)
{
app.DebugPrintf("IOException - %ls\n", e.information.c_str());
this->done;
}
catch (const RuntimeException &e)
{
app.DebugPrintf("RuntimeException - %ls\n", e.information.c_str());
this->done;
}
catch (const IllegalArgumentException &e)
{
app.DebugPrintf("IllegalArgumentException - %ls\n", e.information.c_str());
this->done;
}
catch (const EOFException &e)
{
app.DebugPrintf("EOFException - %ls\n", e.information.c_str());
this->done;
}
} }
INetworkPlayer *ClientConnection::getNetworkPlayer() INetworkPlayer *ClientConnection::getNetworkPlayer()

View file

@ -583,30 +583,32 @@ int Connection::runRead(void* lpParam)
con->readThreads++; con->readThreads++;
LeaveCriticalSection(cs); LeaveCriticalSection(cs);
//try { try {
MemSect(19);
while (con->running && !con->quitting && ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads))
{
while (con->readTick())
;
MemSect(19); // try {
while (con->running && !con->quitting && ShutdownManager::ShouldRun(ShutdownManager::eConnectionReadThreads)) //Sleep(100L);
{ // TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well
while (con->readTick()) con->m_hWakeReadThread->WaitForSignal(100L);
; }
MemSect(0);
// try {
//Sleep(100L);
// TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well
con->m_hWakeReadThread->WaitForSignal(100L);
} }
MemSect(0); catch (EOFException e)
{
/* 4J JEV, removed try/catch app.DebugPrintf("EOFException - %ls\n", e.information.c_str());
} catch (InterruptedException e) { con->running = false;
} con->quitting = true;
} }
} finally { catch (IOException e)
synchronized (threadCounterLock) { {
readThreads--; app.DebugPrintf("IOException - %ls\n", e.information.c_str());
} con->running = false;
} */ con->quitting = true;
}
ShutdownManager::HasFinished(ShutdownManager::eConnectionReadThreads); ShutdownManager::HasFinished(ShutdownManager::eConnectionReadThreads);
return 0; return 0;