diff options
| author | 2019-07-16 15:11:21 +0100 | |
|---|---|---|
| committer | 2019-07-16 16:48:18 +0100 | |
| commit | cd8b456f979733525941284639d8bf899173b429 (patch) | |
| tree | f1d26962e61c74c5acb076662a909beafbe8e5fd /src/inspsocket.cpp | |
| parent | Replace socketengine_{pthread,win32} with C++11 threads. (diff) | |
| parent | ssl_gnutls: remove PackageInfo directives for EOL Debian versions. (diff) | |
Merge branch 'insp3' into master.
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 5e05a4fc0..beafccc35 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) |
