|
@@ -409,51 +409,36 @@ void CVCMIServer::threadHandleClient(std::shared_ptr<CConnection> c)
|
|
|
setThreadName("CVCMIServer::handleConnection");
|
|
|
c->enterLobbyConnectionMode();
|
|
|
|
|
|
-#ifndef _MSC_VER
|
|
|
- try
|
|
|
+ while(c->connected)
|
|
|
{
|
|
|
-#endif
|
|
|
- while(c->connected)
|
|
|
+ CPack * pack;
|
|
|
+
|
|
|
+ try
|
|
|
{
|
|
|
- CPack * pack;
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- pack = c->retrievePack();
|
|
|
- }
|
|
|
- catch(boost::system::system_error & e)
|
|
|
- {
|
|
|
+ pack = c->retrievePack();
|
|
|
+ }
|
|
|
+ catch(boost::system::system_error & e)
|
|
|
+ {
|
|
|
+ if (e.code() == boost::asio::error::eof)
|
|
|
+ logNetwork->error("Network error receiving a pack. Connection has been closed");
|
|
|
+ else
|
|
|
logNetwork->error("Network error receiving a pack. Connection %s dies. What happened: %s", c->toString(), e.what());
|
|
|
- hangingConnections.insert(c);
|
|
|
- connections.erase(c);
|
|
|
- if(connections.empty() || hostClient == c)
|
|
|
- state = EServerState::SHUTDOWN;
|
|
|
|
|
|
- if(gh && state == EServerState::GAMEPLAY)
|
|
|
- {
|
|
|
- gh->handleClientDisconnection(c);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+ hangingConnections.insert(c);
|
|
|
+ connections.erase(c);
|
|
|
+ if(connections.empty() || hostClient == c)
|
|
|
+ state = EServerState::SHUTDOWN;
|
|
|
|
|
|
- CVCMIServerPackVisitor visitor(*this, this->gh);
|
|
|
- pack->visit(visitor);
|
|
|
+ if(gh && state == EServerState::GAMEPLAY)
|
|
|
+ {
|
|
|
+ gh->handleClientDisconnection(c);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
-#ifndef _MSC_VER
|
|
|
- }
|
|
|
- catch(const std::exception & e)
|
|
|
- {
|
|
|
- (void)e;
|
|
|
- boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
|
|
- logNetwork->error("%s dies... \nWhat happened: %s", c->toString(), e.what());
|
|
|
- }
|
|
|
- catch(...)
|
|
|
- {
|
|
|
- state = EServerState::SHUTDOWN;
|
|
|
- handleException();
|
|
|
- throw;
|
|
|
+
|
|
|
+ CVCMIServerPackVisitor visitor(*this, this->gh);
|
|
|
+ pack->visit(visitor);
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
|
|
|
|
@@ -1022,7 +1007,7 @@ static void handleCommandOptions(int argc, const char * argv[], boost::program_o
|
|
|
{
|
|
|
po::store(po::parse_command_line(argc, argv, opts), options);
|
|
|
}
|
|
|
- catch(std::exception & e)
|
|
|
+ catch(po::error & e)
|
|
|
{
|
|
|
std::cerr << "Failure during parsing command-line options:\n" << e.what() << std::endl;
|
|
|
}
|
|
@@ -1113,10 +1098,6 @@ int main(int argc, const char * argv[])
|
|
|
logNetwork->error(e.what());
|
|
|
server.state = EServerState::SHUTDOWN;
|
|
|
}
|
|
|
- catch(...)
|
|
|
- {
|
|
|
- handleException();
|
|
|
- }
|
|
|
}
|
|
|
catch(boost::system::system_error & e)
|
|
|
{
|