From ce774a0a3d9caa96e69daf0db26936c1aa02cd6d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 3 Apr 2026 14:43:13 +0100 Subject: Move a function only used by ssl_openssl into that module. --- modules/extra/ssl_openssl.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'modules/extra/ssl_openssl.cpp') diff --git a/modules/extra/ssl_openssl.cpp b/modules/extra/ssl_openssl.cpp index a95833557..9844d6f5f 100644 --- a/modules/extra/ssl_openssl.cpp +++ b/modules/extra/ssl_openssl.cpp @@ -700,6 +700,26 @@ private: return str ? str : "UNKNOWN"; } + static void FlattenSendQueue(StreamSocket::SendQueue& sendq, size_t targetsize) + { + if ((sendq.size() <= 1) || (sendq.front().length() >= targetsize)) + return; + + // Avoid multiple repeated TLS 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: OpenSSLIOHook(const std::shared_ptr& hookprov, StreamSocket* sock, SSL* session) : SSLIOHook(hookprov) -- cgit v1.3.1-10-gc9f91