* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: resolver.c,v 1.375 2008/07/24 04:54:44 jinmei Exp $ */
+/* $Id: resolver.c,v 1.376 2008/08/06 06:11:15 marka Exp $ */
/*! \file */
* Number of queries that reference this context.
*/
unsigned int nqueries;
+
+ /*%
+ * The reason to print when logging a successful
+ * response to a query.
+ */
+ const char * reason;
};
#define FCTX_MAGIC ISC_MAGIC('F', '!', '!', '!')
}
}
+static inline void
+log_edns(fetchctx_t *fctx) {
+ char domainbuf[DNS_NAME_FORMATSIZE];
+
+ if (fctx->reason == NULL)
+ return;
+
+ dns_name_format(&fctx->domain, domainbuf, sizeof(domainbuf));
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_EDNS_DISABLED,
+ DNS_LOGMODULE_RESOLVER, ISC_LOG_INFO,
+ "success resolving '%s' (in '%s'?) after %s",
+ fctx->info, domainbuf, fctx->reason);
+
+ fctx->reason = NULL;
+}
+
static void
fctx_done(fetchctx_t *fctx, isc_result_t result) {
dns_resolver_t *res;
res = fctx->res;
- if (result == ISC_R_SUCCESS)
+ if (result == ISC_R_SUCCESS) {
+ /*%
+ * Log any deferred EDNS timeout messages.
+ */
+ log_edns(fctx);
no_response = ISC_TRUE;
- else
+ } else
no_response = ISC_FALSE;
+
+ fctx->reason = NULL;
fctx_stopeverything(fctx, no_response);
LOCK(&res->buckets[fctx->bucketnum].lock);
ISC_LIST_INITANDAPPEND(fctx->edns512, sa, link);
}
-static inline void
-log_edns(fetchctx_t *fctx) {
- char domainbuf[DNS_NAME_FORMATSIZE];
-
- dns_name_format(&fctx->domain, domainbuf, sizeof(domainbuf));
- isc_log_write(dns_lctx, DNS_LOGCATEGORY_EDNS_DISABLED,
- DNS_LOGMODULE_RESOLVER, ISC_LOG_INFO,
- "too many timeouts resolving '%s' (in '%s'?): "
- "disabling EDNS", fctx->info, domainbuf);
-}
-
static isc_result_t
resquery_send(resquery_t *query) {
fetchctx_t *fctx;
!useedns)
{
query->options |= DNS_FETCHOPT_NOEDNS0;
- dns_adb_changeflags(fctx->adb,
- query->addrinfo,
+ dns_adb_changeflags(fctx->adb, query->addrinfo,
DNS_FETCHOPT_NOEDNS0,
DNS_FETCHOPT_NOEDNS0);
}
+ /* Sync NOEDNS0 flag in addrinfo->flags and options now */
+ if ((query->addrinfo->flags & DNS_FETCHOPT_NOEDNS0) != 0)
+ query->options |= DNS_FETCHOPT_NOEDNS0;
+
/*
* Use EDNS0, unless the caller doesn't want it, or we know that
* the remote server doesn't like it.
fctx->timeouts >= (MAX_EDNS0_TIMEOUTS * 2)) &&
(query->options & DNS_FETCHOPT_NOEDNS0) == 0) {
query->options |= DNS_FETCHOPT_NOEDNS0;
- log_edns(fctx);
+ fctx->reason = "disabling EDNS";
} else if ((triededns(fctx, &query->addrinfo->sockaddr) ||
fctx->timeouts >= MAX_EDNS0_TIMEOUTS) &&
(query->options & DNS_FETCHOPT_NOEDNS0) == 0) {
query->options |= DNS_FETCHOPT_EDNS512;
- FCTXTRACE("too many timeouts, setting EDNS size to 512");
+ fctx->reason = "reducing UDP packet size to 512";
}
if ((query->options & DNS_FETCHOPT_NOEDNS0) == 0) {
FCTXTRACE("timeout");
if (event->ev_type == ISC_TIMEREVENT_LIFE) {
+ fctx->reason = NULL;
fctx_done(fctx, ISC_R_TIMEDOUT);
} else {
isc_result_t result;
fctx->attributes = 0;
fctx->spilled = ISC_FALSE;
fctx->nqueries = 0;
+ fctx->reason = NULL;
dns_name_init(&fctx->nsname, NULL);
fctx->nsfetch = NULL;