s4: Fix result check for getaddrinfo()
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Wed, 6 Jan 2010 11:40:33 +0000 (13:40 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 6 Jan 2010 13:26:32 +0000 (14:26 +0100)
I think this completes commit 50feca550eed7828198b7c0fc5f0e5ddc863313d.
Now result should be handled correctly both for systems that
support EAI_NODATA but returns EAI_NONAME (as my Ubuntu 9.x)
and systems that doesn't support EAI_NODATA at all.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source4/libcli/resolve/dns_ex.c

index 1b5037273a257aa71b059d8220bb12b5acee84fa..79ed78340c4b471c6baeae24d7efd38ab9ad1172 100644 (file)
@@ -283,14 +283,19 @@ static void run_child_getaddrinfo(struct dns_ex_state *state, int fd)
        hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
 
        ret = getaddrinfo(state->name.name, "0", &hints, &res_list);
+       /* try to fallback in case of error */
+       if (state->do_fallback) {
+               switch (ret) {
 #ifdef EAI_NODATA
-       if (ret == EAI_NODATA && state->do_fallback) {
-#else
-       if (ret == EAI_NONAME && state->do_fallback) {
+               case EAI_NODATA:
 #endif
-               /* getaddrinfo() doesn't handle CNAME records */
-               run_child_dns_lookup(state, fd);
-               return;
+               case EAI_NONAME:
+                       /* getaddrinfo() doesn't handle CNAME records */
+                       run_child_dns_lookup(state, fd);
+                       return;
+               default:
+                       break;
+               }
        }
        if (ret != 0) {
                goto done;