Moving send buf limitation to its proper place.
This commit is contained in:
@@ -44,9 +44,7 @@ SenderHelper::Send(boost::shared_ptr<SessionData> session, boost::shared_ptr<Net
|
||||
SendDataManager &tmpManager = session->GetSendDataManager();
|
||||
// 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<SessionData> 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());
|
||||
|
||||
@@ -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<SendDataManager>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user