isc_time_t expires;
isc_time_t expires_try_stale;
isc_time_t next_timeout;
- isc_time_t final;
isc_interval_t interval;
dns_message_t *qmessage;
ISC_LIST(resquery_t) queries;
*/
static inline isc_result_t
fctx_starttimer(fetchctx_t *fctx) {
- return (isc_timer_reset(fctx->timer, isc_timertype_once, &fctx->final,
- NULL, true));
+ isc_interval_t interval;
+ isc_time_t now;
+ isc_time_t expires;
+
+ isc_interval_set(&interval, 2, 0);
+ isc_time_add(&fctx->expires, &interval, &expires);
+
+ isc_time_now(&now);
+ if (isc_time_compare(&expires, &now) <= 0) {
+ isc_interval_set(&interval, 0, 1);
+ } else {
+ isc_time_t tmp;
+ isc_interval_set(&interval, isc_time_seconds(&now),
+ isc_time_nanoseconds(&now));
+ isc_time_subtract(&expires, &interval, &tmp);
+ isc_interval_set(&interval, isc_time_seconds(&tmp),
+ isc_time_nanoseconds(&tmp));
+ }
+
+ return (isc_timer_reset(fctx->timer, isc_timertype_once, NULL,
+ &interval, true));
}
static inline void
UNLOCK(&res->buckets[bucketnum].lock);
+ /*
+ * As a backstop, we also set a timer to stop the fetch
+ * if in-band netmgr timeouts don't work. It will fire two
+ * seconds after the fetch should have finished. (This
+ * should be enough of a gap to avoid the timer firing
+ * while a response is being processed normally.)
+ */
result = fctx_starttimer(fctx);
if (result != ISC_R_SUCCESS) {
fctx_done(fctx, result, __LINE__);
goto cleanup_qmessage;
}
- /*
- * As a backstop, we also set a timer to stop the fetch
- * if in-band netmgr timeouts don't work. It will fire two
- * seconds after the fetch should have finished. (This
- * should be enough of a gap to avoid the timer firing
- * while a response is being processed normally.)
- */
- isc_interval_set(&interval, 2, 0);
- iresult = isc_time_add(&fctx->expires, &interval, &fctx->final);
- if (iresult != ISC_R_SUCCESS) {
- UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_time_add: %s",
- isc_result_totext(iresult));
- result = ISC_R_UNEXPECTED;
- goto cleanup_qmessage;
- }
-
/*
* Create an inactive timer to enforce maximum query
* lifetime. It will be made active when the fetch is
isc_result_totext(result));
}
} else {
+ isc_interval_t interval;
if (isc_time_compare(&next, now) <= 0) {
- next = *now;
+ isc_interval_set(&interval, 0, 1);
+ } else {
+ /*
+ * In theory, we could just type isc_interval_t to
+ * isc_time_t and back, but there's no such guarantee,
+ * so a safer method is being used here.
+ */
+ isc_time_t tmp;
+ isc_interval_set(&interval, isc_time_seconds(now),
+ isc_time_nanoseconds(now));
+ isc_time_subtract(&next, &interval, &tmp);
+ isc_interval_set(&interval, isc_time_seconds(&tmp),
+ isc_time_nanoseconds(&tmp));
}
- result = isc_timer_reset(zone->timer, isc_timertype_once, &next,
- NULL, true);
+
+ result = isc_timer_reset(zone->timer, isc_timertype_once, NULL,
+ &interval, true);
if (result != ISC_R_SUCCESS) {
dns_zone_log(zone, ISC_LOG_ERROR,
"could not reset zone timer: %s",