mirror of https://github.com/Icinga/icinga2.git
Merge pull request #10214 from Icinga/useless-http-coroutines
HttpServerConnection: Don't spawn useless coroutines
This commit is contained in:
commit
3218908595
|
@ -68,14 +68,21 @@ void HttpServerConnection::Start()
|
|||
IoEngine::SpawnCoroutine(m_IoStrand, [this, keepAlive](asio::yield_context yc) { CheckLiveness(yc); });
|
||||
}
|
||||
|
||||
void HttpServerConnection::Disconnect()
|
||||
/**
|
||||
* Tries to asynchronously shut down the SSL stream and underlying socket.
|
||||
*
|
||||
* It is important to note that this method should only be called from within a coroutine that uses `m_IoStrand`.
|
||||
*
|
||||
* @param yc boost::asio::yield_context The coroutine yield context which you are calling this method from.
|
||||
*/
|
||||
void HttpServerConnection::Disconnect(boost::asio::yield_context yc)
|
||||
{
|
||||
namespace asio = boost::asio;
|
||||
|
||||
HttpServerConnection::Ptr keepAlive (this);
|
||||
if (m_ShuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
IoEngine::SpawnCoroutine(m_IoStrand, [this, keepAlive](asio::yield_context yc) {
|
||||
if (!m_ShuttingDown) {
|
||||
m_ShuttingDown = true;
|
||||
|
||||
Log(LogInformation, "HttpServerConnection")
|
||||
|
@ -104,8 +111,6 @@ void HttpServerConnection::Disconnect()
|
|||
if (listener) {
|
||||
listener->RemoveHttpClient(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void HttpServerConnection::StartStreaming()
|
||||
|
@ -126,7 +131,7 @@ void HttpServerConnection::StartStreaming()
|
|||
m_Stream->async_read_some(readBuf, yc[ec]);
|
||||
} while (!ec);
|
||||
|
||||
Disconnect();
|
||||
Disconnect(yc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -563,7 +568,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
|
|||
}
|
||||
}
|
||||
|
||||
Disconnect();
|
||||
Disconnect(yc);
|
||||
}
|
||||
|
||||
void HttpServerConnection::CheckLiveness(boost::asio::yield_context yc)
|
||||
|
@ -582,7 +587,7 @@ void HttpServerConnection::CheckLiveness(boost::asio::yield_context yc)
|
|||
Log(LogInformation, "HttpServerConnection")
|
||||
<< "No messages for HTTP connection have been received in the last 10 seconds.";
|
||||
|
||||
Disconnect();
|
||||
Disconnect(yc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ public:
|
|||
HttpServerConnection(const String& identity, bool authenticated, const Shared<AsioTlsStream>::Ptr& stream);
|
||||
|
||||
void Start();
|
||||
void Disconnect();
|
||||
void StartStreaming();
|
||||
|
||||
bool Disconnected();
|
||||
|
@ -45,6 +44,8 @@ private:
|
|||
|
||||
HttpServerConnection(const String& identity, bool authenticated, const Shared<AsioTlsStream>::Ptr& stream, boost::asio::io_context& io);
|
||||
|
||||
void Disconnect(boost::asio::yield_context yc);
|
||||
|
||||
void ProcessMessages(boost::asio::yield_context yc);
|
||||
void CheckLiveness(boost::asio::yield_context yc);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue