diff options
author | Florent Le Coz <louiz@louiz.org> | 2015-07-09 15:30:24 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2015-07-09 15:30:24 +0200 |
commit | ece4b4969b296a3da010fb22768348650e70962d (patch) | |
tree | ea7151861b9b3c90b9cbb64410cbe1be8041eb77 /louloulibs | |
parent | ac6a74595c679c22ae13eca0609a745e431b339c (diff) | |
download | biboumi-ece4b4969b296a3da010fb22768348650e70962d.tar.gz biboumi-ece4b4969b296a3da010fb22768348650e70962d.tar.bz2 biboumi-ece4b4969b296a3da010fb22768348650e70962d.tar.xz biboumi-ece4b4969b296a3da010fb22768348650e70962d.zip |
If hostname resolution fails, do not try all possible ports
Diffstat (limited to 'louloulibs')
-rw-r--r-- | louloulibs/network/tcp_socket_handler.cpp | 9 | ||||
-rw-r--r-- | louloulibs/network/tcp_socket_handler.hpp | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/louloulibs/network/tcp_socket_handler.cpp b/louloulibs/network/tcp_socket_handler.cpp index e20357b..04bb321 100644 --- a/louloulibs/network/tcp_socket_handler.cpp +++ b/louloulibs/network/tcp_socket_handler.cpp @@ -40,15 +40,16 @@ TCPSocketHandler::TCPSocketHandler(std::shared_ptr<Poller> poller): SocketHandler(poller, -1), use_tls(false), connected(false), - connecting(false) + connecting(false), #ifdef CARES_FOUND - ,resolving(false), + resolving(false), resolved(false), resolved4(false), resolved6(false), cares_addrinfo(nullptr), - cares_error() + cares_error(), #endif + hostname_resolution_failed(false) {} TCPSocketHandler::~TCPSocketHandler() @@ -109,6 +110,7 @@ void TCPSocketHandler::connect(const std::string& address, const std::string& po addr_res = this->cares_addrinfo; if (!addr_res) { + this->hostname_resolution_failed = true; const auto msg = this->cares_error; this->close(); this->on_connection_failed(msg); @@ -129,6 +131,7 @@ void TCPSocketHandler::connect(const std::string& address, const std::string& po if (res != 0) { log_warning("getaddrinfo failed: "s + gai_strerror(res)); + this->hostname_resolution_failed = true; this->close(); this->on_connection_failed(gai_strerror(res)); return ; diff --git a/louloulibs/network/tcp_socket_handler.hpp b/louloulibs/network/tcp_socket_handler.hpp index 0dde2cf..8069825 100644 --- a/louloulibs/network/tcp_socket_handler.hpp +++ b/louloulibs/network/tcp_socket_handler.hpp @@ -256,6 +256,8 @@ protected: std::string cares_error; #endif // CARES_FOUND + bool hostname_resolution_failed; + private: TCPSocketHandler(const TCPSocketHandler&) = delete; TCPSocketHandler(TCPSocketHandler&&) = delete; |