From c9a5a6f2140758c0ed08764a07dd454a8f3ff986 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Jan 2018 21:56:40 +0100 Subject: connect: Store the IP used when picking a connection There's no real point in storing the IP address while resolving it - failure messages include the IP address in any case. Do this when picking the connection for actual use instead. --- methods/connect.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'methods') diff --git a/methods/connect.cc b/methods/connect.cc index c1a9d347f..07427c651 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -141,6 +141,11 @@ struct Connection std::unique_ptr Take() { + /* Store the IP we are using.. If something goes + wrong this will get tacked onto the end of the error message */ + std::stringstream ss; + ioprintf(ss, _("[IP: %s %s]"), Name, Service); + Owner->SetIP(ss.str()); return std::move(Fd); } @@ -157,15 +162,6 @@ ResultState Connection::DoConnect(unsigned long TimeOut) // if that addr did timeout before, we do not try it again if(bad_addr.find(std::string(Name)) != bad_addr.end()) return ResultState::TRANSIENT_ERROR; - - /* If this is an IP rotation store the IP we are using.. If something goes - wrong this will get tacked onto the end of the error message */ - if (LastHostAddr->ai_next != 0) - { - std::stringstream ss; - ioprintf(ss, _("[IP: %s %s]"),Name,Service); - Owner->SetIP(ss.str()); - } // Get a socket if ((static_cast(Fd.get())->fd = socket(Addr->ai_family, Addr->ai_socktype, -- cgit v1.2.3