Compare commits

...

3 Commits

Author SHA1 Message Date
876a9c82cd Bump copyright year to 2023 2023-03-06 21:08:45 +01:00
fb5b0eeeb9 Make socket connection state mismatch into a fatal error
These problems are usually not ephemeral, and cause persistent console
spam, so they should immediately crash the server so they can be
investigated.
2023-03-06 02:21:54 +01:00
7aabc507e7 Stop handling the current packet if the server is shutting down
Previously, terminating a running server from the terminal would
sometimes print a benign warning message if the server was currently
handling an incoming packet. This happened because CNServer::step()
would continue handling the packet after CNServer::kill() released the
activeCrit mutex. Now it first re-checks if active has been set to false
in the mean time after acquiring the mutex.
2023-03-06 02:21:54 +01:00
2 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2022 OpenFusion Contributors Copyright (c) 2020-2023 OpenFusion Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -473,10 +473,15 @@ void CNServer::start() {
} else { } else {
std::lock_guard<std::mutex> lock(activeCrit); // protect operations on connections std::lock_guard<std::mutex> lock(activeCrit); // protect operations on connections
// halt packet handling if server is shutting down
if (!active)
return;
// player sockets // player sockets
if (connections.find(fds[i].fd) == connections.end()) { if (connections.find(fds[i].fd) == connections.end()) {
std::cout << "[WARN] Event on non-existant socket?" << std::endl; std::cout << "[FATAL] Event on non-existent socket: " << fds[i].fd << std::endl;
continue; // just to be safe assert(0);
/* not reached */
} }
CNSocket* cSock = connections[fds[i].fd]; CNSocket* cSock = connections[fds[i].fd];