Add try catch around packet handling for sql error

This commit is contained in:
David Markowitz 2023-01-06 22:51:19 -08:00
parent a580e3a2f5
commit 05c67fd712
4 changed files with 21 additions and 15 deletions

View File

@ -17,7 +17,7 @@ __dynamic=1
# Set __compile_backtrace__ to 1 to compile the backtrace library instead of using system libraries.
# __compile_backtrace__=1
# Set to the number of jobs (make -j equivalent) to compile the mariadbconn files with.
__maria_db_connector_compile_jobs__=1
__maria_db_connector_compile_jobs__=
# When set to 1 and uncommented, compiling and linking testing folders and libraries will be done.
__enable_testing__=1
# The path to OpenSSL. Change this if your OpenSSL install path is different than the default.

View File

@ -9,5 +9,5 @@ cd build
cmake ..
# To build utilizing multiple cores, append `-j` and the amount of cores to utilize, for example `cmake --build . --config Release -j8'
cmake --build . --config Release
cmake --build . --config Release -j

View File

@ -42,7 +42,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
Entity* entity = EntityManager::Instance()->GetEntity(objectID);
User* usr = UserManager::Instance()->GetUser(sysAddr);
Game::logger->Log("GameMessageHandler", "handling message %i", messageID);
if (!entity) {
Game::logger->Log("GameMessageHandler", "Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID);

View File

@ -413,21 +413,27 @@ int main(int argc, char** argv) {
UserManager::Instance()->DeletePendingRemovals();
auto t1 = std::chrono::high_resolution_clock::now();
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
packet = Game::server->Receive();
if (packet) {
auto t1 = std::chrono::high_resolution_clock::now();
HandlePacket(packet);
auto t2 = std::chrono::high_resolution_clock::now();
try {
auto t1 = std::chrono::high_resolution_clock::now();
for (uint32_t curPacket = 0; curPacket < maxPacketsToProcess && timeSpent < maxPacketProcessingTime; curPacket++) {
packet = Game::server->Receive();
if (packet) {
auto t1 = std::chrono::high_resolution_clock::now();
HandlePacket(packet);
auto t2 = std::chrono::high_resolution_clock::now();
timeSpent += std::chrono::duration_cast<std::chrono::duration<float>>(t2 - t1).count();
Game::server->DeallocatePacket(packet);
packet = nullptr;
} else {
break;
timeSpent += std::chrono::duration_cast<std::chrono::duration<float>>(t2 - t1).count();
Game::server->DeallocatePacket(packet);
packet = nullptr;
} else {
break;
}
}
} catch (sql::SQLException& e) {
Game::logger->Log("WorldServer", "Caught an error (%s)", e.what());
std::raise(SIGTERM);
}
Metrics::EndMeasurement(MetricVariable::PacketHandling);