aboutsummaryrefslogtreecommitdiffstats
path: root/include/modules
diff options
context:
space:
mode:
authorGravatar Attila Molnar2015-06-06 14:42:59 +0200
committerGravatar Attila Molnar2015-06-06 14:42:59 +0200
commitd0556a2a598e207ab468b7ea4543e427205ef903 (patch)
treead4bd402d060fdaa384f118891e5da13018afdee /include/modules
parentAdd max outgoing record size option to sslprofile config (diff)
Call OnStreamSocketWrite() once per write event
Do sendq flattening in SSL modules, move code for it into class SSLIOHook from core
Diffstat (limited to 'include/modules')
-rw-r--r--include/modules/ssl.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/modules/ssl.h b/include/modules/ssl.h
index 0f58e0b7b..67bfc7b2e 100644
--- a/include/modules/ssl.h
+++ b/include/modules/ssl.h
@@ -138,6 +138,31 @@ class SSLIOHook : public IOHook
*/
reference<ssl_cert> certificate;
+ /** Reduce elements in a send queue by appending later elements to the first element until there are no more
+ * elements to append or a desired length is reached
+ * @param sendq SendQ to work on
+ * @param targetsize Target size of the front element
+ */
+ static void FlattenSendQueue(StreamSocket::SendQueue& sendq, size_t targetsize)
+ {
+ if ((sendq.size() <= 1) || (sendq.front().length() >= targetsize))
+ return;
+
+ // Avoid multiple repeated SSL encryption invocations
+ // This adds a single copy of the queue, but avoids
+ // much more overhead in terms of system calls invoked
+ // by an IOHook.
+ std::string tmp;
+ tmp.reserve(std::min(targetsize, sendq.bytes())+1);
+ do
+ {
+ tmp.append(sendq.front());
+ sendq.pop_front();
+ }
+ while (!sendq.empty() && tmp.length() < targetsize);
+ sendq.push_front(tmp);
+ }
+
public:
SSLIOHook(IOHookProvider* hookprov)
: IOHook(hookprov)