From ad4c05bd3f16f4a70e81cdf253d4a1e5c7fc50f1 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Wed, 29 Jun 2016 09:19:01 +0000 Subject: Re #1926: Fixed bug of premature app callback invocation in DNS A+AAAA resolution when DNS A record is available in the cache. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5369 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip/sip_resolve.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pjsip/src/pjsip/sip_resolve.c b/pjsip/src/pjsip/sip_resolve.c index e97123d6..231a98d8 100644 --- a/pjsip/src/pjsip/sip_resolve.c +++ b/pjsip/src/pjsip/sip_resolve.c @@ -217,10 +217,15 @@ PJ_DEF(void) pjsip_resolve( pjsip_resolver_t *resolver, * really tell the address family type, except when IPv6 flag is * explicitly set. */ +#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6==1 if ((ip_addr_ver == 6) || (type & PJSIP_TRANSPORT_IPV6)) af = pj_AF_INET6(); else if (ip_addr_ver == 4) af = pj_AF_INET(); +#else + /* IPv6 is disabled, will resolving IPv6 address be useful? */ + af = pj_AF_INET(); +#endif /* Set the transport type if not explicitly specified. * RFC 3263 section 4.1 specify rules to set up this. @@ -430,6 +435,15 @@ PJ_DEF(void) pjsip_resolve( pjsip_resolver_t *resolver, /* Resolve DNS A record if address family is not fixed to IPv6 */ if (af != pj_AF_INET6()) { + + /* 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. + */ + if (af == pj_AF_UNSPEC()) + query->object6 = (pj_dns_async_query*)0x1; + status = pj_dns_resolver_start_query(resolver->res, &query->naptr[0].name, PJ_DNS_TYPE_A, 0, -- cgit v1.2.3