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();
}
} }
} }
+7 -1
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,12 +551,16 @@ 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);
} }
if (!errorFlag)
{
session.sessionData->GetAsioSocket()->async_read_some( session.sessionData->GetAsioSocket()->async_read_some(
boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed), boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed),
boost::bind( boost::bind(
@@ -565,6 +570,7 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses
sessionId, sessionId,
boost::asio::placeholders::bytes_transferred)); boost::asio::placeholders::bytes_transferred));
} }
}
else else
{ {
// On error: Close this session. // On error: Close this session.