]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Improve speed of SSL sendq processing
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 21 Sep 2009 21:39:52 +0000 (21:39 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 21 Sep 2009 21:39:52 +0000 (21:39 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11756 e03df62e-2008-0410-955e-edbf42e46eb7

src/inspsocket.cpp

index 1f0aa56292704aa2e968a8f626e2b996a066ee4f..907acea67f78c35c62a34f167f975fee86a58ac7 100644 (file)
@@ -204,6 +204,22 @@ void StreamSocket::DoWrite()
                int rv = -1;
                try
                {
+                       if (sendq.size() > 1 && sendq[0].length() < 1024)
+                       {
+                               // 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 the IOHook.
+                               //
+                               // 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);
+                       }
                        while (!sendq.empty())
                        {
                                std::string& front = sendq.front();