Fixed a possible race condition in cClientHandle's packet sending code; prepared for moving cSocket out of cClientHandle's ownership.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@832 0a769ca7-a7f5-676a-18bf-c427514a06d6master
parent
b379f35f4f
commit
e3d5da2409
|
@ -1028,7 +1028,7 @@ int cProtocol125::ParseLogin(void)
|
|||
LOGWARNING("Login Username (\"%s\") does not match Handshake username (\"%s\") for client @ \"%s\", kicking",
|
||||
Username.c_str(),
|
||||
m_Username.c_str(),
|
||||
m_Client->GetSocket().GetIPString().c_str()
|
||||
m_Client->GetIPString().c_str()
|
||||
);
|
||||
m_Client->Kick("Hacked client"); // Don't tell them why we don't want them
|
||||
return PARSE_OK;
|
||||
|
|
|
@ -1546,8 +1546,11 @@ void cClientHandle::DataReceived(const char * a_Data, int a_Size)
|
|||
void cClientHandle::GetOutgoingData(AString & a_Data)
|
||||
{
|
||||
// Data can be sent to client
|
||||
m_OutgoingData.ReadAll(a_Data);
|
||||
m_OutgoingData.CommitRead();
|
||||
{
|
||||
cCSLock Lock(m_CSOutgoingData);
|
||||
m_OutgoingData.ReadAll(a_Data);
|
||||
m_OutgoingData.CommitRead();
|
||||
}
|
||||
|
||||
// Disconnect player after all packets have been sent
|
||||
if (m_bKicking && a_Data.empty())
|
||||
|
|
|
@ -60,8 +60,8 @@ public:
|
|||
cClientHandle(const cSocket & a_Socket, int a_ViewDistance);
|
||||
~cClientHandle();
|
||||
|
||||
const cSocket & GetSocket(void) const {return m_Socket; }
|
||||
cSocket & GetSocket(void) {return m_Socket; }
|
||||
cSocket & GetSocket (void) { return m_Socket; }
|
||||
const AString & GetIPString(void) const { return m_Socket.GetIPString(); }
|
||||
|
||||
cPlayer* GetPlayer() { return m_Player; } // tolua_export
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
|
|||
, m_FoodTickTimer(0)
|
||||
{
|
||||
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
|
||||
a_PlayerName.c_str(), a_Client->GetSocket().GetIPString().c_str(),
|
||||
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
|
||||
this, GetUniqueID()
|
||||
);
|
||||
m_EntityType = eEntityType_Player;
|
||||
|
|
|
@ -510,7 +510,7 @@ void cServer::ServerCommand(const AString & a_Cmd)
|
|||
{
|
||||
virtual bool Item(cPlayer * a_Player) override
|
||||
{
|
||||
LOG("\t%s @ %s", a_Player->GetName().c_str(), a_Player->GetClientHandle()->GetSocket().GetIPString().c_str());
|
||||
LOG("\t%s @ %s", a_Player->GetName().c_str(), a_Player->GetClientHandle()->GetIPString().c_str());
|
||||
return false;
|
||||
}
|
||||
} Logger;
|
||||
|
|
Loading…
Reference in New Issue