diff options
author | bbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-07-08 21:00:01 +0000 |
---|---|---|
committer | bbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-07-08 21:00:01 +0000 |
commit | 58438598f6da07d9d993bc8e7577f7b9c4ef8cea (patch) | |
tree | 8e9a693e7fa17da065334a16d148af63f7faaf5b | |
parent | 8b49aad36466ab8bf0abdf16273ee6cd769bda43 (diff) |
Fix a bug in SRV lookups where dnsmgr would discard everything but the
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: http://svn.digium.com/svn/asterisk/trunk@129156 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | main/dns.c | 6 | ||||
-rw-r--r-- | main/dnsmgr.c | 3 | ||||
-rw-r--r-- | main/srv.c | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/main/dns.c b/main/dns.c index 4884406cb..ad1673830 100644 --- a/main/dns.c +++ b/main/dns.c @@ -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 diff --git a/main/dnsmgr.c b/main/dnsmgr.c index cae20f4b7..727d8b5fc 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -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", diff --git a/main/srv.c b/main/srv.c index 3950e255f..1899e8b8f 100644 --- a/main/srv.c +++ b/main/srv.c @@ -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 |