From 351d32659f0c2b594f63ad537e3dfd04dc78b68e Mon Sep 17 00:00:00 2001 From: lotodore Date: Tue, 2 Oct 2007 18:58:54 +0000 Subject: [PATCH] Fixed server termination issue. --- src/pokerth_server.cpp | 3 ++- src/session.cpp | 16 +++++++++++----- src/session.h | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/pokerth_server.cpp b/src/pokerth_server.cpp index f2c73c2f..b96d1020 100644 --- a/src/pokerth_server.cpp +++ b/src/pokerth_server.cpp @@ -93,7 +93,8 @@ main(int argc, char *argv[]) myServerGuiInterface->getSession().startNetworkServer(); while (!g_pokerthTerminate) { - myServerGuiInterface->getSession().waitForNetworkServer(100); + if (myServerGuiInterface->getSession().waitForNetworkServer(100)) + g_pokerthTerminate = true; } myServerGuiInterface->getSession().terminateNetworkServer(); diff --git a/src/session.cpp b/src/session.cpp index d9e560bf..0b7b2b30 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -235,15 +235,21 @@ void Session::terminateNetworkServer() myNetServer = 0; } -void Session::waitForNetworkServer(unsigned timeoutMsec) +bool Session::waitForNetworkServer(unsigned timeoutMsec) { + bool retVal = false; if (!myNetServer) - return; // already terminated - if (myNetServer->Join(timeoutMsec)) + retVal = true; // already terminated + else { - delete myNetServer; - myNetServer = 0; + if (myNetServer->Join(timeoutMsec)) + { + delete myNetServer; + myNetServer = 0; + retVal = true; + } } + return retVal; } void Session::startIrcClient() diff --git a/src/session.h b/src/session.h index 2c1d4f91..1b6f91fb 100755 --- a/src/session.h +++ b/src/session.h @@ -60,7 +60,7 @@ public: void sendLeaveCurrentGame(); void sendStartEvent(bool fillUpWithCpuPlayers); void terminateNetworkServer(); - void waitForNetworkServer(unsigned timeoutMsec); + bool waitForNetworkServer(unsigned timeoutMsec); void startIrcClient(); void sendIrcChatMessage(const std::string &message);