Отправка клиенту больше данных чем нужно.
Отправляем - сколько выделили памяти для буфера, а не сколько туда положили. Баг, как вижу старый, на трине присутствует тоже
...
У меня трафик снизился после исправления.
Собственно код для чистого ядра:
PHP код:
--- WorldSocket.cpp
+++ WorldSocket.cpp
@@ -164,36 +164,36 @@
if (closing_)
return -1;
// Dump outgoing packet.
sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), LookupOpcodeName(pct.GetOpcode()), &pct, false);
- ServerPktHeader header(pct.size()+2, pct.GetOpcode());
+ ServerPktHeader header(pct.wpos()+ 2, pct.GetOpcode());
m_Crypt.EncryptSend ((uint8*)header.header, header.getHeaderLength());
- if (m_OutBuffer->space () >= pct.size () + header.getHeaderLength() && msg_queue()->is_empty())
+ if (m_OutBuffer->space() >= pct.wpos()+ header.getHeaderLength() && msg_queue()->is_empty())
{
// Put the packet on the buffer.
- if (m_OutBuffer->copy ((char*) header.header, header.getHeaderLength()) == -1)
+ if (m_OutBuffer->copy((char*)header.header, header.getHeaderLength()) == -1)
MANGOS_ASSERT (false);
- if (!pct.empty ())
- if (m_OutBuffer->copy ((char*) pct.contents (), pct.size ()) == -1)
+ if (pct.wpos() > 0)
+ if (m_OutBuffer->copy((char*)pct.contents(), pct.wpos()) == -1)
- MANGOS_ASSERT (false);
+ MANGOS_ASSERT(false);
}
else
{
// Enqueue the packet.
ACE_Message_Block* mb;
- ACE_NEW_RETURN(mb, ACE_Message_Block(pct.size () + header.getHeaderLength()), -1);
+ ACE_NEW_RETURN(mb, ACE_Message_Block(pct.wpos()+ header.getHeaderLength()), -1);
mb->copy((char*) header.header, header.getHeaderLength());
- if (!pct.empty ())
- mb->copy((const char*)pct.contents(), pct.size ());
+ if (pct.wpos() > 0)
+ mb->copy((const char*)pct.contents(), pct.wpos());
if(msg_queue()->enqueue_tail(mb,(ACE_Time_Value*)&ACE_Time_Value::zero) == -1)
{
sLog.outError("WorldSocket::SendPacket enqueue_tail");
mb->release();
return -1;
@@ -774,13 +774,13 @@
{
packet.Initialize (SMSG_AUTH_RESPONSE, 1);
packet << uint8 (AUTH_VERSION_MISMATCH);
SendPacket (packet);
- sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch).");
+ sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch). Client build: %u", ClientBuild);
return -1;
}
// Get the account information from the realmd database
std::string safe_account = account; // Duplicate, else will screw the SHA hash verification below
LoginDatabase.escape_string (safe_account);
PHP код:
--- WorldSession.cpp
+++ WorldSession.cpp
@@ -35,12 +35,15 @@
#include "BattleGroundMgr.h"
#include "MapManager.h"
#include "SocialMgr.h"
#include "Auth/AuthCrypt.h"
#include "Auth/HMACSHA1.h"
#include "zlib/zlib.h"
// select opcodes appropriate for processing in Map::Update context for current session state
static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& opHandle)
{
// we do not process thread-unsafe packets
if (opHandle.packetProcessing == PROCESS_THREADUNSAFE)
@@ -147,16 +150,16 @@
time_t cur_time = time(NULL);
if((cur_time - lastTime) < 60)
{
sendPacketCount+=1;
- sendPacketBytes+=packet->size();
+ sendPacketBytes += packet->wpos();
sendLastPacketCount+=1;
- sendLastPacketBytes+=packet->size();
+ sendLastPacketBytes += packet->wpos();
}
else
{
uint64 minTime = uint64(cur_time - lastTime);
uint64 fullTime = uint64(lastTime - firstTime);
DETAIL_LOG("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u",sendPacketCount,sendPacketBytes,float(sendPacketCount)/fullTime,float(sendPacketBytes)/fullTime,uint32(fullTime));
@@ -179,22 +182,22 @@
_recvQueue.add(new_packet);
}
/// Logging helper for unexpected opcodes
void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char *reason)
{
- sLog.outError( "SESSION: received unexpected opcode %s (0x%.4X) %s",
+ sLog.outDebug("SESSION: received unexpected opcode %s (0x%.4X) %s",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode(),
reason);
}
/// Logging helper for unexpected opcodes
void WorldSession::LogUnprocessedTail(WorldPacket *packet)
{
- sLog.outError( "SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")",
+ sLog.outDebug("SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at "SIZEFMTD" from "SIZEFMTD")",
LookupOpcodeName(packet->GetOpcode()),
packet->GetOpcode(),
packet->rpos(),packet->wpos());
}
/// Update the WorldSession (triggered by World update)