mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 15:37:20 +00:00
Merge pull request #416 from Marcono1234/MasterServer-closing-db
Fix MasterServer not always closing database connection on exit
This commit is contained in:
commit
5e5fefb501
@ -67,7 +67,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
//Create all the objects we need to run our service:
|
//Create all the objects we need to run our service:
|
||||||
Game::logger = SetupLogger();
|
Game::logger = SetupLogger();
|
||||||
if (!Game::logger) return 0;
|
if (!Game::logger) return EXIT_FAILURE;
|
||||||
|
|
||||||
Game::logger->Log("MasterServer", "Starting Master server...\n");
|
Game::logger->Log("MasterServer", "Starting Master server...\n");
|
||||||
Game::logger->Log("MasterServer", "Version: %i.%i\n", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
|
Game::logger->Log("MasterServer", "Version: %i.%i\n", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
|
||||||
@ -84,7 +84,7 @@ int main(int argc, char** argv) {
|
|||||||
std::ifstream cdclient_fd(cdclient_path);
|
std::ifstream cdclient_fd(cdclient_path);
|
||||||
if (!cdclient_fd.good()) {
|
if (!cdclient_fd.good()) {
|
||||||
Game::logger->Log("WorldServer", "%s could not be opened\n", cdclient_path.c_str());
|
Game::logger->Log("WorldServer", "%s could not be opened\n", cdclient_path.c_str());
|
||||||
return -1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
cdclient_fd.close();
|
cdclient_fd.close();
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ int main(int argc, char** argv) {
|
|||||||
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database\n");
|
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database\n");
|
||||||
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
||||||
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
|
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
|
||||||
return -1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get CDClient initial information
|
//Get CDClient initial information
|
||||||
@ -106,7 +106,7 @@ int main(int argc, char** argv) {
|
|||||||
Game::logger->Log("WorldServer", "May be caused by corrupted file: %s\n", cdclient_path.c_str());
|
Game::logger->Log("WorldServer", "May be caused by corrupted file: %s\n", cdclient_path.c_str());
|
||||||
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
||||||
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
|
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
|
||||||
return -1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Connect to the MySQL Database
|
//Connect to the MySQL Database
|
||||||
@ -119,7 +119,7 @@ int main(int argc, char** argv) {
|
|||||||
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
|
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
|
||||||
} catch (sql::SQLException& ex) {
|
} catch (sql::SQLException& ex) {
|
||||||
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
|
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the first command line argument is -a or --account then make the user
|
//If the first command line argument is -a or --account then make the user
|
||||||
@ -167,7 +167,11 @@ int main(int argc, char** argv) {
|
|||||||
delete statement;
|
delete statement;
|
||||||
|
|
||||||
std::cout << "Account created successfully!\n";
|
std::cout << "Account created successfully!\n";
|
||||||
return 0;
|
|
||||||
|
Database::Destroy();
|
||||||
|
delete Game::logger;
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxClients = 999;
|
int maxClients = 999;
|
||||||
@ -267,7 +271,8 @@ int main(int argc, char** argv) {
|
|||||||
//10m shutdown for universe kill command
|
//10m shutdown for universe kill command
|
||||||
if (shouldShutdown) {
|
if (shouldShutdown) {
|
||||||
if (framesSinceKillUniverseCommand >= 40000) {
|
if (framesSinceKillUniverseCommand >= 40000) {
|
||||||
std::exit(0);
|
//Break main loop and exit
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
framesSinceKillUniverseCommand++;
|
framesSinceKillUniverseCommand++;
|
||||||
@ -320,7 +325,7 @@ int main(int argc, char** argv) {
|
|||||||
delete Game::server;
|
delete Game::server;
|
||||||
delete Game::logger;
|
delete Game::logger;
|
||||||
|
|
||||||
return 0;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
dLogger* SetupLogger() {
|
dLogger* SetupLogger() {
|
||||||
|
Loading…
Reference in New Issue
Block a user