1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Don't close the server socket while another thread is using it.

This commit is contained in:
Frank Zago 2009-06-06 15:17:07 +00:00
parent 83432e30c0
commit e0c600b963
2 changed files with 9 additions and 3 deletions

View File

@ -87,6 +87,7 @@ void CClient::init()
serv = NULL;
gs = NULL;
cb = NULL;
must_close = false;
try
{
shared = new SharedMem();
@ -124,6 +125,11 @@ void CClient::run()
CPack *pack;
while(1)
{
if (must_close) {
serv->close();
tlog3 << "Our socket has been closed.\n";
return;
}
//get the package from the server
{
@ -162,8 +168,7 @@ void CClient::close()
boost::unique_lock<boost::mutex>(*serv->wmx);
*serv << &CloseServer();
tlog3 << "Sent closing signal to the server\n";
serv->close();
tlog3 << "Our socket has been closed.\n";
must_close = true;
}
void CClient::save(const std::string & fname)
@ -399,4 +404,4 @@ void CClient::serialize( Handler &h, const int version )
}
template void CClient::serialize( CISer<CLoadFile> &h, const int version );
template void CClient::serialize( COSer<CSaveFile> &h, const int version );
template void CClient::serialize( COSer<CSaveFile> &h, const int version );

View File

@ -58,6 +58,7 @@ public:
std::set<CCallback*> callbacks; //callbacks given to player interfaces
std::map<ui8,CGameInterface *> playerint;
CConnection *serv;
bool must_close;
SharedMem *shared;
BattleAction *curbaction;