mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 10:17:59 +02:00
ApiListener#AddConnection(): start connect timeout after DNS resolution
ASIO DNS resolution can't be cancelled. If it takes longer than ApiListener#connect_timeout, the latter becomes a no-op as it cancels socket I/O which doesn't even start before DNS resolution.
This commit is contained in:
parent
4a05070555
commit
e814697af5
@ -584,6 +584,8 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
|
|||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
|
auto ips (Resolve(host, port, yc));
|
||||||
|
|
||||||
Timeout::Ptr timeout(new Timeout(strand->context(), *strand, boost::posix_time::microseconds(int64_t(GetConnectTimeout() * 1e6)),
|
Timeout::Ptr timeout(new Timeout(strand->context(), *strand, boost::posix_time::microseconds(int64_t(GetConnectTimeout() * 1e6)),
|
||||||
[sslConn, endpoint, host, port](asio::yield_context yc) {
|
[sslConn, endpoint, host, port](asio::yield_context yc) {
|
||||||
Log(LogCritical, "ApiListener")
|
Log(LogCritical, "ApiListener")
|
||||||
@ -596,7 +598,7 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
|
|||||||
));
|
));
|
||||||
Defer cancelTimeout([&timeout]() { timeout->Cancel(); });
|
Defer cancelTimeout([&timeout]() { timeout->Cancel(); });
|
||||||
|
|
||||||
Connect(sslConn->lowest_layer(), host, port, yc);
|
Connect(sslConn->lowest_layer(), ips, yc);
|
||||||
|
|
||||||
NewClientHandler(yc, strand, sslConn, endpoint->GetName(), RoleClient);
|
NewClientHandler(yc, strand, sslConn, endpoint->GetName(), RoleClient);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user