Fixed server termination issue.

This commit is contained in:
lotodore
2007-10-02 18:58:54 +00:00
parent 73c90d4106
commit 351d32659f
3 changed files with 14 additions and 7 deletions
+2 -1
View File
@@ -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();
+11 -5
View File
@@ -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()
+1 -1
View File
@@ -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);