diff --git a/src/net/common/senderhelper.cpp b/src/net/common/senderhelper.cpp index 8f5aa29e..f4617ac7 100644 --- a/src/net/common/senderhelper.cpp +++ b/src/net/common/senderhelper.cpp @@ -44,9 +44,7 @@ SenderHelper::Send(boost::shared_ptr session, boost::shared_ptrGetSendDataManager(); // Add packet to specific queue. boost::mutex::scoped_lock lock(tmpManager.dataMutex); - if (tmpManager.GetAllocated() <= MAX_SEND_BUF_SIZE) { - InternalStorePacket(tmpManager, packet); - } + InternalStorePacket(tmpManager, packet); // Activate async send, if needed. tmpManager.AsyncSendNextPacket(session->GetAsioSocket()); } @@ -59,14 +57,12 @@ SenderHelper::Send(boost::shared_ptr session, const NetPacketList & SendDataManager &tmpManager = session->GetSendDataManager(); // Add packets to specific queue. boost::mutex::scoped_lock lock(tmpManager.dataMutex); - if (tmpManager.GetAllocated() <= MAX_SEND_BUF_SIZE) { - NetPacketList::const_iterator i = packetList.begin(); - NetPacketList::const_iterator end = packetList.end(); - while (i != end) { - if (*i) - InternalStorePacket(tmpManager, *i); - ++i; - } + NetPacketList::const_iterator i = packetList.begin(); + NetPacketList::const_iterator end = packetList.end(); + while (i != end) { + if (*i) + InternalStorePacket(tmpManager, *i); + ++i; } // Activate async send, if needed. tmpManager.AsyncSendNextPacket(session->GetAsioSocket()); diff --git a/src/net/senddatamanager.h b/src/net/senddatamanager.h index be35bb29..ecf73ed2 100644 --- a/src/net/senddatamanager.h +++ b/src/net/senddatamanager.h @@ -28,7 +28,7 @@ #define SEND_BUF_FIRST_ALLOC_CHUNKSIZE 4096 -#define MAX_SEND_BUF_SIZE SEND_BUF_FIRST_ALLOC_CHUNKSIZE * 1000 +#define MAX_SEND_BUF_SIZE SEND_BUF_FIRST_ALLOC_CHUNKSIZE * 256 class SendDataManager : public boost::enable_shared_from_this @@ -52,11 +52,13 @@ public: if (0 == allocAmount) { allocAmount = (size_t)SEND_BUF_FIRST_ALLOC_CHUNKSIZE; } - char *tempBuf = (char *)std::realloc(sendBuf, allocAmount); - if (tempBuf) { - sendBuf = tempBuf; - sendBufAllocated = allocAmount; - retVal = true; + if (allocAmount <= MAX_SEND_BUF_SIZE) { + char *tempBuf = (char *)std::realloc(sendBuf, allocAmount); + if (tempBuf) { + sendBuf = tempBuf; + sendBufAllocated = allocAmount; + retVal = true; + } } return retVal; }