X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=907acea67f78c35c62a34f167f975fee86a58ac7;hb=58895f9b1daa1e13927462d046a36dec853a40e0;hp=964582062db41f2e4daec79154c81c177d645cdb;hpb=e2af2347fc035d702e45f12e772223a8d578410d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 964582062..907acea67 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -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(); @@ -296,6 +312,12 @@ void StreamSocket::DoWrite() void StreamSocket::WriteData(const std::string &data) { + if (fd < 0) + { + ServerInstance->Logs->Log("SOCKET", DEBUG, "Attempt to write data to dead socket: %s", + data.c_str()); + return; + } bool newWrite = sendq.empty() && !data.empty(); /* Append the data to the back of the queue ready for writing */