Fixing possible server issues.
This commit is contained in:
@@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user