From bca0857db0dd362805572316d03b327629cfc414 Mon Sep 17 00:00:00 2001 From: Nicolas 'Pixel' Noble Date: Thu, 17 Jan 2013 00:03:31 -0800 Subject: Slightly changing the resolution error message; plus that condition was stupid. --- src/Socket.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/Socket.cc') diff --git a/src/Socket.cc b/src/Socket.cc index 6df1988..ccd1011 100644 --- a/src/Socket.cc +++ b/src/Socket.cc @@ -325,13 +325,12 @@ bool Balau::Socket::setLocal(const char * hostname, int port) { DNSRequest req = resolveName(hostname, NULL, &hints); struct addrinfo * res = req.res; if (req.error != 0) { - freeaddrinfo(res); - return false; - } - if (!res) { - freeaddrinfo(res); + Printer::elog(E_SOCKET, "Got a resolution error for host %s: %s (%i)", hostname, gai_strerror(req.error), req.error); + if (res) + freeaddrinfo(res); return false; } + IAssert(res, "That really shouldn't happen..."); EAssert(res->ai_family == AF_INET6, "getaddrinfo returned a familiy which isn't AF_INET6; %i", res->ai_family); EAssert(res->ai_protocol == IPPROTO_TCP, "getaddrinfo returned a protocol which isn't IPPROTO_TCP; %i", res->ai_protocol); EAssert(res->ai_addrlen == sizeof(sockaddr_in6), "getaddrinfo returned an addrlen which isn't that of sizeof(sockaddr_in6); %i", res->ai_addrlen); @@ -376,13 +375,12 @@ bool Balau::Socket::connect(const char * hostname, int port) { DNSRequest req = resolveName(hostname, NULL, &hints); struct addrinfo * res = req.res; if (req.error != 0) { - freeaddrinfo(res); - return false; - } - if (!res) { - freeaddrinfo(res); + Printer::elog(E_SOCKET, "Got a resolution error for host %s: %s (%i)", hostname, gai_strerror(req.error), req.error); + if (res) + freeaddrinfo(res); return false; } + IAssert(res, "That really shouldn't happen..."); Printer::elog(E_SOCKET, "Got a resolution answer"); EAssert(res->ai_family == AF_INET6, "getaddrinfo returned a familiy which isn't AF_INET6; %i", res->ai_family); EAssert(res->ai_protocol == IPPROTO_TCP, "getaddrinfo returned a protocol which isn't IPPROTO_TCP; %i", res->ai_protocol); -- cgit v1.2.3