Skip to content
Permalink
Browse files

Handle exceptions during VM shutdowns better

For each vm there was one try/catch handling DropErr which sent the
shutdown message and called Free(). But either one of these can throw
DropErr and Free should still be called, so there should be two
try/catch blocks.
  • Loading branch information...
slipher committed Apr 21, 2019
1 parent 9de7646 commit c1d9716ad6bf5ff8f9efb98f0590debe5984819c
Showing with 14 additions and 6 deletions.
  1. +7 −3 src/engine/client/cl_cgame.cpp
  2. +7 −3 src/engine/server/sv_sgame.cpp
@@ -323,7 +323,6 @@ void CL_ShutdownCGame()
}

cgvm.CGameShutdown();
cgvm.Free();
}

/*
@@ -1030,11 +1029,16 @@ void CGameVM::CGameInit(int serverMessageNum, int clientNum)

void CGameVM::CGameShutdown()
{
// Ignore errors when shutting down
try {
this->SendMsg<CGameShutdownMsg>();
} catch (Sys::DropErr& err) {
Log::Notice("Error during cgame shutdown: %s", err.what());
}
try {
this->Free();
} catch (Sys::DropErr&) {}
} catch (Sys::DropErr& err) {
Log::Notice("Error while freeing cgame: %s", err.what());
}
services = nullptr;
}

@@ -268,7 +268,6 @@ void SV_ShutdownGameProgs()
}

gvm.GameShutdown( false );
gvm.Free();
}

/*
@@ -363,11 +362,16 @@ void GameVM::GameInit(int levelTime, int randomSeed)

void GameVM::GameShutdown(bool restart)
{
// Ignore errors when shutting down
try {
this->SendMsg<GameShutdownMsg>(restart);
} catch (Sys::DropErr& err) {
Log::Notice("Error during sgame shutdown: %s", err.what());
}
try {
this->Free();
} catch (Sys::DropErr&) {}
} catch (Sys::DropErr& err) {
Log::Notice("Error while freeing sgame: %s", err.what());
}
services = nullptr;

// Release the shared memory region

0 comments on commit c1d9716

Please sign in to comment.
You can’t perform that action at this time.