提交 9036ed08 authored 作者: Michael Jerris's avatar Michael Jerris

Tue Jun 23 09:58:14 CDT 2009 Pekka Pessi <first.last@nokia.com>

  * sres.c: use original query with callback when doing CNAME recurse



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13922 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 7b8332d2
Tue Jun 23 14:47:41 CDT 2009 Tue Jun 23 14:48:11 CDT 2009
...@@ -324,7 +324,6 @@ struct sres_query_s { ...@@ -324,7 +324,6 @@ struct sres_query_s {
uint16_t q_retry_count; uint16_t q_retry_count;
uint8_t q_n_servers; uint8_t q_n_servers;
uint8_t q_i_server; uint8_t q_i_server;
int8_t q_aliased;
int8_t q_edns; int8_t q_edns;
uint8_t q_n_subs; uint8_t q_n_subs;
sres_query_t *q_subqueries[1 + SRES_MAX_SEARCH]; sres_query_t *q_subqueries[1 + SRES_MAX_SEARCH];
...@@ -404,6 +403,7 @@ static int sres_config_changed_servers(sres_config_t const *new_c, ...@@ -404,6 +403,7 @@ static int sres_config_changed_servers(sres_config_t const *new_c,
sres_config_t const *old_c); sres_config_t const *old_c);
static sres_server_t **sres_servers_new(sres_resolver_t *res, static sres_server_t **sres_servers_new(sres_resolver_t *res,
sres_config_t const *c); sres_config_t const *c);
static sres_answer_f sres_resolving_cname;
/** Generate new 16-bit identifier for DNS query. */ /** Generate new 16-bit identifier for DNS query. */
static void static void
...@@ -3083,15 +3083,35 @@ sres_resend_dns_query(sres_resolver_t *res, sres_query_t *q, int timeout) ...@@ -3083,15 +3083,35 @@ sres_resend_dns_query(sres_resolver_t *res, sres_query_t *q, int timeout)
static void static void
sres_resolve_cname(sres_resolver_t *res, sres_resolve_cname(sres_resolver_t *res,
const sres_query_t *orig_query, sres_query_t *orig_query,
const char *alias) char const *cname)
{ {
sres_query_t *query; sres_query_t *query;
query = sres_query_alloc(res, query = sres_query_alloc(res,
orig_query->q_callback, orig_query->q_context, orig_query->q_type, sres_resolving_cname,
alias); (sres_context_t *)orig_query,
query->q_aliased = 1; orig_query->q_type,
sres_send_dns_query(res, query); cname);
if (query)
sres_send_dns_query(res, query);
else
sres_query_report_error(orig_query, NULL);
}
static void
sres_resolving_cname(sres_context_t *original_query,
sres_query_t *query,
sres_record_t **answers)
{
sres_query_t *orig = (sres_query_t *)original_query;
/* Notify the listener */
if (orig->q_callback != NULL)
(orig->q_callback)(orig->q_context, orig, answers);
sres_free_query(orig->q_res, orig);
} }
/** Get a server by socket */ /** Get a server by socket */
...@@ -3486,17 +3506,18 @@ sres_resolver_receive(sres_resolver_t *res, int socket) ...@@ -3486,17 +3506,18 @@ sres_resolver_receive(sres_resolver_t *res, int socket)
if (sres_cache_get(res->res_cache, query->q_type, alias, &cached) if (sres_cache_get(res->res_cache, query->q_type, alias, &cached)
> 0) { > 0) {
reply = cached; reply = cached;
} else { }
/* Resubmit the query with the aliased name, dropping this result */ else {
/* Submit a query with the aliased name, dropping this result */
sres_resolve_cname(res, query, alias); sres_resolve_cname(res, query, alias);
reply = NULL; return 1;
} }
} }
if (reply) {
/* Notify the listener */ /* Notify the listener */
if (query->q_callback != NULL) if (query->q_callback != NULL)
(query->q_callback)(query->q_context, query, reply); (query->q_callback)(query->q_context, query, reply);
}
sres_free_query(res, query); sres_free_query(res, query);
} }
else { else {
...@@ -3670,7 +3691,8 @@ sres_decode_msg(sres_resolver_t *res, ...@@ -3670,7 +3691,8 @@ sres_decode_msg(sres_resolver_t *res,
} }
if (m->m_ancount > 0 && errorcount == 0 && query->q_type < sres_qtype_tsig if (m->m_ancount > 0 && errorcount == 0 && query->q_type < sres_qtype_tsig
&& (query->q_aliased || answers[0]->sr_type != sres_type_cname)) { && (query->q_callback == sres_resolving_cname ||
answers[0]->sr_type != sres_type_cname)) {
for (i = 0; i < m->m_ancount; i++) { for (i = 0; i < m->m_ancount; i++) {
if (query->q_type == answers[i]->sr_type) if (query->q_type == answers[i]->sr_type)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论