Browse files

Do not send too much data over SSL in one go

Some clients fail to read it entirely and the remaining data stays in their read buffer until new data arrives
  • Loading branch information...
1 parent 71d64de commit 7dd381f568938971e9c69a074def5da058d5c242 @attilamolnar attilamolnar committed Jun 19, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/inspsocket.cpp
View
12 src/inspsocket.cpp
@@ -248,11 +248,13 @@ void StreamSocket::DoWrite()
// The length limit of 1024 is to prevent merging strings
// more than once when writes begin to block.
std::string tmp;
- tmp.reserve(sendq_len);
- for(unsigned int i=0; i < sendq.size(); i++)
- tmp.append(sendq[i]);
- sendq.clear();
- sendq.push_back(tmp);
+ tmp.reserve(1280);
+ while (!sendq.empty() && tmp.length() < 1024)
+ {
+ tmp.append(sendq.front());
+ sendq.pop_front();
+ }
+ sendq.push_front(tmp);
}
std::string& front = sendq.front();
int itemlen = front.length();

0 comments on commit 7dd381f

Please sign in to comment.