]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a bug in SRV lookups where dnsmgr would discard everything but the
authorBrett Bryant <bbryant@digium.com>
Tue, 8 Jul 2008 21:00:01 +0000 (21:00 +0000)
committerBrett Bryant <bbryant@digium.com>
Tue, 8 Jul 2008 21:00:01 +0000 (21:00 +0000)
first SRV result from DNS before processing weights and priorities and
dns_parse_answer wouldn't report that there were no records in DNS
unless a failure occured. Also fixed a bug where dnsmgr_refresh would
report that a entry was being changed when ast_gethostbyname had failed.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@129156 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/dns.c
main/dnsmgr.c
main/srv.c

index 4884406cb4a000274d12f9b9e5c09fa473d5e940..ad1673830d4ce62f1623a57b39f9f64a8b716cdc 100644 (file)
@@ -189,6 +189,7 @@ static int dns_parse_answer(void *context,
        unsigned char *fullanswer = answer;
        struct dn_answer *ans;
        dns_HEADER *h;
+       int ret = 0;
        int res;
        int x;
 
@@ -234,14 +235,13 @@ static int dns_parse_answer(void *context,
                                        ast_log(LOG_WARNING, "Failed to parse result\n");
                                        return -1;
                                }
-                               if (res > 0)
-                                       return 1;
+                               ret = 1;
                        }
                }
                answer += ntohs(ans->size);
                len -= ntohs(ans->size);
        }
-       return 0;
+       return ret;
 }
 
 #ifndef HAVE_RES_NINIT
index cae20f4b7c3e8e43e6af5db6ec68460bb5b34b0d..727d8b5fcce552c4ebc322db16ff6a43df2aa6ea 100644 (file)
@@ -164,8 +164,7 @@ static int dnsmgr_refresh(struct ast_dnsmgr_entry *entry, int verbose)
        if (verbose)
                ast_verb(3, "refreshing '%s'\n", entry->name);
 
-       ast_get_ip_or_srv(&tmp, entry->name, entry->service);
-       if (inaddrcmp(&tmp, &entry->last)) {
+       if (!ast_get_ip_or_srv(&tmp, entry->name, entry->service) && inaddrcmp(&tmp, &entry->last)) {
                ast_copy_string(iabuf, ast_inet_ntoa(entry->last.sin_addr), sizeof(iabuf));
                ast_copy_string(iabuf2, ast_inet_ntoa(tmp.sin_addr), sizeof(iabuf2));
                ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s:%d to %s:%d\n", 
index 3950e255f23869942773ca0cefb3a4e98d3ab724..1899e8b8f4e2534fe249bc84a993bece65731fdc 100644 (file)
@@ -137,7 +137,7 @@ static int srv_callback(void *context, unsigned char *answer, int len, unsigned
        if (entry)
                AST_LIST_INSERT_TAIL(&c->entries, entry, list);
 
-       return 1;
+       return 0;
 }
 
 /* Do the bizarre SRV record weight-handling algorithm