From: JINMEI Tatuya Date: Fri, 1 Jul 2011 17:43:25 +0000 (-0700) Subject: [trac1069] throw an exception when getSockAddr fails (which shouldn't happen) X-Git-Tag: perftcpdns_before_epoll~231^2~19^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac06e0bbad2fd39f8cc77fac06fc397be14f92c2;p=thirdparty%2Fkea.git [trac1069] throw an exception when getSockAddr fails (which shouldn't happen) instead of returning a dummy structure, expecting it to cause a subsequent failure. --- diff --git a/src/lib/acl/tests/sockaddr.h b/src/lib/acl/tests/sockaddr.h index 11d63872df..bac1f6eb82 100644 --- a/src/lib/acl/tests/sockaddr.h +++ b/src/lib/acl/tests/sockaddr.h @@ -19,6 +19,8 @@ #include #include +#include + namespace isc { namespace acl { namespace tests { @@ -35,7 +37,8 @@ inline const struct sockaddr& getSockAddr(const char* const addr) { struct addrinfo hints, *res; memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; + //hints.ai_family = AF_UNSPEC; + hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_NUMERICHOST; @@ -48,11 +51,11 @@ getSockAddr(const char* const addr) { } // We don't expect getaddrinfo to fail for our tests. But if that - // ever happens we return a dummy value that would make subsequent test - // fail. - static struct sockaddr sa_dummy; - sa_dummy.sa_family = AF_UNSPEC; - return (sa_dummy); + // ever happens we throw an exception to make sure the corresponding test + // fail (either due to a failure of *_NO_THROW or the uncaught exception). + isc_throw(Unexpected, + "failed to convert textual IP address to sockaddr for " << + addr); } } // end of namespace "tests"