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

@@ -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);