Commit c15e8d5d authored by Pekka Pessi's avatar Pekka Pessi

sres.c: improve logging upon errors

Ignore-this: d6c04be7f7ef57e4a48fe487e850da1e

darcs-hash:20090212202026-db55f-88a96bb52d2d618b09208454f2676a6dc9d74159.gz
parent c6f586ba
......@@ -71,7 +71,10 @@ enum sres_status {
/* Errors generated by sresolv */
SRES_TIMEOUT_ERR = 32, /**< Timeout occurred */
SRES_RECORD_ERR = 33 /**< Name has no given record type */
SRES_RECORD_ERR = 33, /**< Name has no given record type */
SRES_INTERNAL_ERR = 34, /**< Internal error */
_SRES_LAST_ERR
};
/** Start of a zone of authority record (@RFC1035). */
......@@ -248,6 +251,9 @@ enum sres_qtypes {
/** Convert type to its name. */
SRESPUBFUN char const *sres_record_type(int type, char buffer[8]);
/** Convert status to its name. */
SRESPUBFUN char const *sres_record_status(int status, char buffer[8]);
/** Compare two records. */
SRESPUBFUN int sres_record_compare(sres_record_t const *,
sres_record_t const *);
......
......@@ -1538,6 +1538,30 @@ char const *sres_record_type(int type, char buffer[8])
}
}
/** Convert record status to its name */
char const *sres_record_status(int status, char buffer[8])
{
switch (status) {
case SRES_OK: return "OK";
case SRES_FORMAT_ERR: return "FORMAT_ERR";
case SRES_SERVER_ERR: return "SERVER_ERR";
case SRES_NAME_ERR: return "NAME_ERR";
case SRES_UNIMPL_ERR: return "UNIMPL_ERR";
case SRES_AUTH_ERR: return "AUTH_ERR";
/* Errors generated by sresolv */
case SRES_TIMEOUT_ERR: return "TIMEOUT_ERR";
case SRES_RECORD_ERR: return "RECORD_ERR";
case SRES_INTERNAL_ERR: return "INTERNAL_ERR";
default:
if (buffer)
sprintf(buffer, "%u?", status & 255);
return buffer;
}
}
/** Convert class to its name. */
static char const *
sres_record_class(int rclass, char buffer[8])
......@@ -2899,6 +2923,9 @@ sres_query_report_error(sres_query_t *q,
int i;
if (q->q_callback) {
char sbuf[8], tbuf[8];
int status = 0;
for (i = 0; i <= SRES_MAX_SEARCH; i++) {
if (q->q_subqueries[i]) /* a pending query... */
return;
......@@ -2910,8 +2937,16 @@ sres_query_report_error(sres_query_t *q,
}
}
SU_DEBUG_5(("sres(q=%p): reporting errors for %u %s\n",
(void *)q, q->q_type, q->q_name));
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",
(void *)q,
sres_record_status(status, sbuf),
sres_record_type(q->q_type, tbuf), q->q_name));
sres_remove_query(q->q_res, q, 1);
(q->q_callback)(q->q_context, q, answers);
......@@ -3567,7 +3602,9 @@ sres_decode_msg(sres_resolver_t *res,
}
if (i < total) {
SU_DEBUG_5(("sres_decode_msg: %s\n", "less records than promised"));
SU_DEBUG_5(("sres_decode_msg: got %u but expected "
"errors=%u an=%u ar=%u ns=%u\n", i, errorcount,
m->m_ancount, m->m_arcount, m->m_nscount));
for (i = 0; i < total; i++)
sres_cache_free_record(res->res_cache, answers[i]);
su_free(chome, answers);
......
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