Moving send buf limitation to its proper place.

This commit is contained in:
lotodore
2011-02-19 15:19:50 +00:00
parent f7315cd9e5
commit b824b8beb7
2 changed files with 15 additions and 17 deletions
+7 -11
View File
@@ -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());
+8 -6
View File
@@ -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;
}