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();
|
SendDataManager &tmpManager = session->GetSendDataManager();
|
||||||
// Add packet to specific queue.
|
// Add packet to specific queue.
|
||||||
boost::mutex::scoped_lock lock(tmpManager.dataMutex);
|
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.
|
// Activate async send, if needed.
|
||||||
tmpManager.AsyncSendNextPacket(session->GetAsioSocket());
|
tmpManager.AsyncSendNextPacket(session->GetAsioSocket());
|
||||||
}
|
}
|
||||||
@@ -59,14 +57,12 @@ SenderHelper::Send(boost::shared_ptr<SessionData> session, const NetPacketList &
|
|||||||
SendDataManager &tmpManager = session->GetSendDataManager();
|
SendDataManager &tmpManager = session->GetSendDataManager();
|
||||||
// Add packets to specific queue.
|
// Add packets to specific queue.
|
||||||
boost::mutex::scoped_lock lock(tmpManager.dataMutex);
|
boost::mutex::scoped_lock lock(tmpManager.dataMutex);
|
||||||
if (tmpManager.GetAllocated() <= MAX_SEND_BUF_SIZE) {
|
NetPacketList::const_iterator i = packetList.begin();
|
||||||
NetPacketList::const_iterator i = packetList.begin();
|
NetPacketList::const_iterator end = packetList.end();
|
||||||
NetPacketList::const_iterator end = packetList.end();
|
while (i != end) {
|
||||||
while (i != end) {
|
if (*i)
|
||||||
if (*i)
|
InternalStorePacket(tmpManager, *i);
|
||||||
InternalStorePacket(tmpManager, *i);
|
++i;
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Activate async send, if needed.
|
// Activate async send, if needed.
|
||||||
tmpManager.AsyncSendNextPacket(session->GetAsioSocket());
|
tmpManager.AsyncSendNextPacket(session->GetAsioSocket());
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define SEND_BUF_FIRST_ALLOC_CHUNKSIZE 4096
|
#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>
|
class SendDataManager : public boost::enable_shared_from_this<SendDataManager>
|
||||||
@@ -52,11 +52,13 @@ public:
|
|||||||
if (0 == allocAmount) {
|
if (0 == allocAmount) {
|
||||||
allocAmount = (size_t)SEND_BUF_FIRST_ALLOC_CHUNKSIZE;
|
allocAmount = (size_t)SEND_BUF_FIRST_ALLOC_CHUNKSIZE;
|
||||||
}
|
}
|
||||||
char *tempBuf = (char *)std::realloc(sendBuf, allocAmount);
|
if (allocAmount <= MAX_SEND_BUF_SIZE) {
|
||||||
if (tempBuf) {
|
char *tempBuf = (char *)std::realloc(sendBuf, allocAmount);
|
||||||
sendBuf = tempBuf;
|
if (tempBuf) {
|
||||||
sendBufAllocated = allocAmount;
|
sendBuf = tempBuf;
|
||||||
retVal = true;
|
sendBufAllocated = allocAmount;
|
||||||
|
retVal = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user