Skip to content

Commit

Permalink
ApiListener#ListenerCoroutineProc(): get remote endpoint ASAP for log…
Browse files Browse the repository at this point in the history
…ging

On incoming connection timeout we log the remote endpoint which isn't
available if it was already disconnected - an exception is thrown.  Get it
as long as we're still connected not to lose it, nor to get an exception.
  • Loading branch information
Al2Klimov committed Feb 9, 2024
1 parent 01a6c4c commit 62e1d76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/remote/apilistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const Sha

server->async_accept(socket.lowest_layer(), yc);

auto remoteEndpoint (socket.lowest_layer().remote_endpoint());

if (!crlPath.IsEmpty()) {
time_t currentCreationTime = Utility::GetFileCreationTime(crlPath);

Expand All @@ -531,12 +533,11 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const Sha

auto strand (Shared<asio::io_context::strand>::Make(io));

IoEngine::SpawnCoroutine(*strand, [this, strand, sslConn](asio::yield_context yc) {
IoEngine::SpawnCoroutine(*strand, [this, strand, sslConn, remoteEndpoint](asio::yield_context yc) {
Timeout::Ptr timeout(new Timeout(strand->context(), *strand, boost::posix_time::microseconds(int64_t(GetConnectTimeout() * 1e6)),
[sslConn](asio::yield_context yc) {
[sslConn, remoteEndpoint](asio::yield_context yc) {
Log(LogWarning, "ApiListener")
<< "Timeout while processing incoming connection from "
<< sslConn->lowest_layer().remote_endpoint();
<< "Timeout while processing incoming connection from " << remoteEndpoint;

boost::system::error_code ec;
sslConn->lowest_layer().cancel(ec);
Expand Down

0 comments on commit 62e1d76

Please sign in to comment.