[Pkg-voip-commits] [pjproject] 10/14: r5471 svn backport Various fixes for DNS IPv6
Bernhard Schmidt
berni at moszumanska.debian.org
Thu Nov 10 09:32:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
berni pushed a commit to branch master
in repository pjproject.
commit ff04cf8c66bb448f2f30958508de1d0121db9e54
Author: Richard Mudgett <rmudgett at digium.com>
Date: Fri Oct 28 12:11:30 2016 -0500
r5471 svn backport Various fixes for DNS IPv6
Fixed #1974: Various fixes for DNS IPv6
Patch-Category: asterisk
---
pjlib-util/src/pjlib-util/resolver.c | 11 +++++------
pjlib-util/src/pjlib-util/srv_resolver.c | 17 +++++++++++++++--
pjsip/src/pjsip/sip_resolve.c | 14 +++++++-------
3 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/pjlib-util/src/pjlib-util/resolver.c b/pjlib-util/src/pjlib-util/resolver.c
index e5e1bed..d24ef9d 100644
--- a/pjlib-util/src/pjlib-util/resolver.c
+++ b/pjlib-util/src/pjlib-util/resolver.c
@@ -835,7 +835,7 @@ PJ_DEF(pj_status_t) pj_dns_resolver_start_query( pj_dns_resolver *resolver,
pj_time_val now;
struct res_key key;
struct cached_res *cache;
- pj_dns_async_query *q;
+ pj_dns_async_query *q, *p_q = NULL;
pj_uint32_t hval;
pj_status_t status = PJ_SUCCESS;
@@ -849,9 +849,6 @@ PJ_DEF(pj_status_t) pj_dns_resolver_start_query( pj_dns_resolver *resolver,
/* Check type */
PJ_ASSERT_RETURN(type > 0 && type < 0xFFFF, PJ_EINVAL);
- if (p_query)
- *p_query = NULL;
-
/* Build resource key for looking up hash tables */
init_res_key(&key, type, name);
@@ -970,10 +967,12 @@ PJ_DEF(pj_status_t) pj_dns_resolver_start_query( pj_dns_resolver *resolver,
pj_hash_set_np(resolver->hquerybyres, &q->key, sizeof(q->key),
0, q->hbufkey, q);
- if (p_query)
- *p_query = q;
+ p_q = q;
on_return:
+ if (p_query)
+ *p_query = p_q;
+
pj_mutex_unlock(resolver->mutex);
return status;
}
diff --git a/pjlib-util/src/pjlib-util/srv_resolver.c b/pjlib-util/src/pjlib-util/srv_resolver.c
index 02672aa..ff9c979 100644
--- a/pjlib-util/src/pjlib-util/srv_resolver.c
+++ b/pjlib-util/src/pjlib-util/srv_resolver.c
@@ -187,9 +187,12 @@ PJ_DEF(pj_status_t) pj_dns_srv_cancel_query(pj_dns_srv_async_query *query,
has_pending = PJ_TRUE;
}
if (srv->q_aaaa) {
- pj_dns_resolver_cancel_query(srv->q_aaaa, PJ_FALSE);
+ /* Check if it is a dummy query. */
+ if (srv->q_aaaa != (pj_dns_async_query*)0x1) {
+ pj_dns_resolver_cancel_query(srv->q_aaaa, PJ_FALSE);
+ has_pending = PJ_TRUE;
+ }
srv->q_aaaa = NULL;
- has_pending = PJ_TRUE;
}
}
@@ -485,12 +488,22 @@ static pj_status_t resolve_hostnames(pj_dns_srv_async_query *query_job)
srv->common.type = PJ_DNS_TYPE_A;
srv->common_aaaa.type = PJ_DNS_TYPE_AAAA;
srv->parent = query_job;
+ srv->q_a = NULL;
+ srv->q_aaaa = NULL;
status = PJ_SUCCESS;
/* Start DNA A record query */
if ((query_job->option & PJ_DNS_SRV_RESOLVE_AAAA_ONLY) == 0)
{
+ if ((query_job->option & PJ_DNS_SRV_RESOLVE_AAAA) != 0) {
+ /* If there will be DNS AAAA query too, let's setup
+ * a dummy one here, otherwise app callback may be called
+ * immediately (before DNS AAAA query is sent) when
+ * DNS A record is available in the cache.
+ */
+ srv->q_aaaa = (pj_dns_async_query*)0x1;
+ }
status = pj_dns_resolver_start_query(query_job->resolver,
&srv->target_name,
PJ_DNS_TYPE_A, 0,
diff --git a/pjsip/src/pjsip/sip_resolve.c b/pjsip/src/pjsip/sip_resolve.c
index ed326ba..3f3654d 100644
--- a/pjsip/src/pjsip/sip_resolve.c
+++ b/pjsip/src/pjsip/sip_resolve.c
@@ -452,7 +452,7 @@ PJ_DEF(void) pjsip_resolve( pjsip_resolver_t *resolver,
}
/* Resolve DNS AAAA record if address family is not fixed to IPv4 */
- if (af != pj_AF_INET()) {
+ if (af != pj_AF_INET() && status == PJ_SUCCESS) {
status = pj_dns_resolver_start_query(resolver->res,
&query->naptr[0].name,
PJ_DNS_TYPE_AAAA, 0,
@@ -530,9 +530,9 @@ static void dns_a_callback(void *user_data,
++srv->count;
}
-
- } else {
-
+ }
+
+ if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
/* Log error */
@@ -593,9 +593,9 @@ static void dns_aaaa_callback(void *user_data,
++srv->count;
}
-
- } else {
-
+ }
+
+ if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
/* Log error */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/pjproject.git
More information about the Pkg-voip-commits
mailing list