Fixing possible server issues.

This commit is contained in:
lotodore
2009-07-13 22:49:32 +00:00
parent 398805a136
commit 58d471e0de
2 changed files with 18 additions and 9 deletions
+3
View File
@@ -58,7 +58,10 @@ internal_log_err(const string &msg)
{ {
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app); ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail()) if (!o.fail())
{
o << second_clock::local_time() << " ERR: " << msg; o << second_clock::local_time() << " ERR: " << msg;
o.flush();
}
} }
} }
+15 -9
View File
@@ -534,6 +534,7 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses
ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer(); ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer();
buf.recvBufUsed += bytesRead; buf.recvBufUsed += bytesRead;
GetReceiver().ScanPackets(buf); GetReceiver().ScanPackets(buf);
bool errorFlag = false;
while (!buf.receivedPackets.empty()) while (!buf.receivedPackets.empty())
{ {
@@ -550,20 +551,25 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses
} catch (const PokerTHException &e) } catch (const PokerTHException &e)
{ {
LOG_ERROR("Game " << game->GetId() << " - Read handler exception: " << e.what()); LOG_ERROR("Game " << game->GetId() << " - Read handler exception: " << e.what());
InternalRemoveGame(game); game->RemoveAllSessions();
errorFlag = true;
break;
} }
} }
else else
HandlePacket(session, packet); HandlePacket(session, packet);
} }
session.sessionData->GetAsioSocket()->async_read_some( if (!errorFlag)
boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed), {
boost::bind( session.sessionData->GetAsioSocket()->async_read_some(
&ServerLobbyThread::HandleRead, boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed),
this, boost::bind(
boost::asio::placeholders::error, &ServerLobbyThread::HandleRead,
sessionId, this,
boost::asio::placeholders::bytes_transferred)); boost::asio::placeholders::error,
sessionId,
boost::asio::placeholders::bytes_transferred));
}
} }
else else
{ {