Commit ebfe3870 authored by Pekka Pessi's avatar Pekka Pessi

sres.c: improved error handling

Ignore-this: a64e098f8575511bb6e5ef3129635d98

Returning records with SRES_NETWORK_ERR or SRES_TIMEOUT_ERR.
Also setting errno if there is no available DNS servers.

darcs-hash:20090225190935-db55f-aa693bd4c0dd7e4e9c2e0ddba4b9b6a4655f8353.gz
parent 05f1bec9
......@@ -73,6 +73,7 @@ enum sres_status {
SRES_TIMEOUT_ERR = 32, /**< Timeout occurred */
SRES_RECORD_ERR = 33, /**< Name has no given record type */
SRES_INTERNAL_ERR = 34, /**< Internal error */
SRES_NETWORK_ERR = 35, /**< Network or DNS configuration error. */
_SRES_LAST_ERR
};
......
......@@ -1554,6 +1554,7 @@ char const *sres_record_status(int status, char buffer[8])
case SRES_TIMEOUT_ERR: return "TIMEOUT_ERR";
case SRES_RECORD_ERR: return "RECORD_ERR";
case SRES_INTERNAL_ERR: return "INTERNAL_ERR";
case SRES_NETWORK_ERR: return "NETWORK_ERR";
default:
if (buffer)
......@@ -2749,6 +2750,8 @@ sres_send_dns_query(sres_resolver_t *res,
if (i0 > N) i0 = 0; /* Number of DNS servers reduced */
dns = servers[i = i0];
error = EIO;
if (res->res_config->c_opt.rotate || dns->dns_error || dns->dns_icmp)
dns = sres_next_server(res, &q->q_i_server, 1), i = q->q_i_server;
......@@ -2938,10 +2941,21 @@ sres_query_report_error(sres_query_t *q,
}
}
for (i = 0; answers[i]; i++) {
status = answers[i]->sr_record->r_status;
if (status)
break;
if (answers == NULL) {
sres_cache_t *cache = q->q_res->res_cache;
status = q->q_retry_count ? SRES_TIMEOUT_ERR : SRES_NETWORK_ERR;
answers = su_zalloc(CHOME(cache), 2 * sizeof *answers);
if (answers)
answers[0] = sres_create_error_rr(cache, q, status);
}
else {
for (i = 0; answers[i]; i++) {
status = answers[i]->sr_record->r_status;
if (status)
break;
}
}
SU_DEBUG_5(("sres(q=%p): reporting error %s for %s %s\n",
......
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