diff options
| author | 2019-05-22 13:47:17 -0500 | |
|---|---|---|
| committer | 2019-05-22 19:47:17 +0100 | |
| commit | de7011e54ad88656e01c92a88dd053a94b5acc6b (patch) | |
| tree | 713d80e075dd880f0d635eee297bd313441b0337 /src/inspsocket.cpp | |
| parent | m_filter: Minor cosmetic changes (#1645). (diff) | |
Add an overload of StreamSocket::Close which closes when all data has been written.
Fixes sending large pages in m_httpd (#1646).
Diffstat (limited to 'src/inspsocket.cpp')
| -rw-r--r-- | src/inspsocket.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 59d9558a4..684ee051d 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -95,6 +95,10 @@ BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs& void StreamSocket::Close() { + if (closing) + return; + + closing = true; if (this->fd > -1) { // final chance, dump as much of the sendq as we can @@ -114,6 +118,14 @@ void StreamSocket::Close() } } +void StreamSocket::Close(bool writeblock) +{ + if (getSendQSize() != 0 && writeblock) + closeonempty = true; + else + Close(); +} + CullResult StreamSocket::cull() { Close(); @@ -206,7 +218,12 @@ static const int MYIOV_MAX = IOV_MAX < 128 ? IOV_MAX : 128; void StreamSocket::DoWrite() { if (getSendQSize() == 0) + { + if (closeonempty) + Close(); + return; + } if (!error.empty() || fd < 0) { ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "DoWrite on errored or closed socket"); @@ -242,6 +259,9 @@ void StreamSocket::DoWrite() if (psendq) FlushSendQ(*psendq); + + if (getSendQSize() == 0 && closeonempty) + Close(); } void StreamSocket::FlushSendQ(SendQueue& sq) |
