Commit 55d92ef6 authored by Mickaël Turnel's avatar Mickaël Turnel

Check in reception the type of request (dns, mdns) and treat accordingly

parent 9658442c
......@@ -283,6 +283,8 @@ struct sres_resolver_s {
sres_server_t **res_servers;
#if HAVE_MDNS
sres_query_t *res_mdns_query;
sres_socket_t res_mdns_socket;
uint8_t res_mdns;
sres_record_t **res_mdns_answers;
#endif
......@@ -1135,13 +1137,13 @@ sres_mdns_process_srv(void *obj)
if (error == kDNSServiceErr_NoError) {
handle_poll(browse_ref);
sres_notify_resolver(query);
} else {
SU_DEBUG_9(("sres_mdns_process_srv(\"%s\", %i) browse error\n",
query->q_name, error));
}
sres_notify_resolver(query);
return NULL;
}
......@@ -1212,13 +1214,13 @@ sres_mdns_process_a_aaaa(void *obj)
res_it = res_it->ai_next;
} while (res_it != NULL);
sres_notify_resolver(query);
}
if (res)
freeaddrinfo(res);
sres_notify_resolver(query);
return NULL;
}
#endif
......@@ -1332,6 +1334,7 @@ sres_query(sres_resolver_t *res,
#if HAVE_MDNS
if (query && (res->res_mdns || strstr(domain, ".local"))) {
res->res_mdns = 1;
res->res_mdns_query = query;
sres_mdns_query(query);
} else
#endif
......@@ -3561,6 +3564,9 @@ int sres_resolver_sockets(sres_resolver_t *res,
}
return_sockets[i++] = s;
#ifdef HAVE_MDNS
res->res_mdns_socket = s;
#endif
}
return retval;
......@@ -3798,6 +3804,23 @@ sres_resolver_report_error(sres_resolver_t *res,
int
sres_resolver_receive(sres_resolver_t *res, int socket)
{
#ifdef HAVE_MDNS
if (res->res_mdns) {
sres_query_t *query = NULL;
if (query) {
if (res->res_mdns_answers) {
/* Notify the listener */
if (query->q_callback != NULL)
(query->q_callback)(query->q_context, query, res->res_mdns_answers);
sres_free_query(res, query);
} else {
sres_query_report_error(query, res->res_mdns_answers);
}
}
} else {
#endif
ssize_t num_bytes;
int error;
sres_message_t m[1];
......@@ -3891,6 +3914,9 @@ sres_resolver_receive(sres_resolver_t *res, int socket)
else {
sres_query_report_error(query, reply);
}
#ifdef HAVE_MDNS
}
#endif
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment