]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2399. [bug] Abort timeout queries to reduce the number of open
authorTatuya JINMEI 神明達哉 <jinmei@isc.org>
Thu, 24 Jul 2008 05:00:48 +0000 (05:00 +0000)
committerTatuya JINMEI 神明達哉 <jinmei@isc.org>
Thu, 24 Jul 2008 05:00:48 +0000 (05:00 +0000)
UDP sockets. [RT #18367]

CHANGES
lib/dns/resolver.c
lib/isc/include/isc/timer.h
lib/isc/timer.c

diff --git a/CHANGES b/CHANGES
index 24bf23c968402bfa8d467a1549f9a497399f6ce9..8ab8b3a1b2232ed92960320c7017053e526c8129 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2399.  [bug]           Abort timeout queries to reduce the number of open
+                       UDP sockets. [RT #18367]
+
 2398.  [bug]           Improve file descriptor management.  New,
                        temporary, named.conf option reserved-sockets,
                        default 512. [RT #18344]
index a0ed15bac61cbaca9fe9efd6e9e19897b0441a12..cdf5788d7a3b5ed8d75d7c3d153f576f6a98fc84 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resolver.c,v 1.284.18.66.8.3 2008/07/23 07:28:56 tbox Exp $ */
+/* $Id: resolver.c,v 1.284.18.66.8.4 2008/07/24 05:00:48 jinmei Exp $ */
 
 /*! \file */
 
@@ -2689,6 +2689,8 @@ fctx_destroy(fetchctx_t *fctx) {
 static void
 fctx_timeout(isc_task_t *task, isc_event_t *event) {
        fetchctx_t *fctx = event->ev_arg;
+       isc_timerevent_t *tevent = (isc_timerevent_t *)event;
+       resquery_t *query;
 
        REQUIRE(VALID_FCTX(fctx));
 
@@ -2704,8 +2706,18 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) {
                fctx->timeouts++;
                /*
                 * We could cancel the running queries here, or we could let
-                * them keep going.  Right now we choose the latter...
+                * them keep going.  Since we normally use separate sockets for
+                * different queries, we adopt the former approach to reduce
+                * the number of open sockets: cancel the oldest query if it
+                * expired after the query had started (this is usually the
+                * case but is not always so, depending on the task schedule
+                * timing).
                 */
+               query = ISC_LIST_HEAD(fctx->queries);
+               if (query != NULL &&
+                   isc_time_compare(&tevent->due, &query->start) >= 0) {
+                       fctx_cancelquery(&query, NULL, NULL, ISC_TRUE);
+               }
                fctx->attributes &= ~FCTX_ATTR_ADDRWAIT;
                /*
                 * Our timer has triggered.  Reestablish the fctx lifetime
index 1e139dda819d7556209e37d52a8be608949b459d..0246a3a59c4963c84c77f03a31f7fc6d76d8fca5 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: timer.h,v 1.31.18.3 2005/10/26 06:50:50 marka Exp $ */
+/* $Id: timer.h,v 1.31.18.3.52.1 2008/07/24 05:00:48 jinmei Exp $ */
 
 #ifndef ISC_TIMER_H
 #define ISC_TIMER_H 1
@@ -76,6 +76,7 @@
 #include <isc/event.h>
 #include <isc/eventclass.h>
 #include <isc/lang.h>
+#include <isc/time.h>
 
 ISC_LANG_BEGINDECLS
 
@@ -93,6 +94,7 @@ typedef enum {
 
 typedef struct isc_timerevent {
        struct isc_event        common;
+       isc_time_t              due;
 } isc_timerevent_t;
 
 #define ISC_TIMEREVENT_FIRSTEVENT      (ISC_EVENTCLASS_TIMER + 0)
index f67d0910e8bb5f78d7852174b75b69cf1f00721b..77ee823c5deacec01f5b973436624f16f5f6324d 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: timer.c,v 1.73.18.7 2007/10/24 23:46:26 tbox Exp $ */
+/* $Id: timer.c,v 1.73.18.7.10.1 2008/07/24 05:00:48 jinmei Exp $ */
 
 /*! \file */
 
@@ -577,7 +577,7 @@ isc_timer_detach(isc_timer_t **timerp) {
 static void
 dispatch(isc_timermgr_t *manager, isc_time_t *now) {
        isc_boolean_t done = ISC_FALSE, post_event, need_schedule;
-       isc_event_t *event;
+       isc_timerevent_t *event;
        isc_eventtype_t type = 0;
        isc_timer_t *timer;
        isc_result_t result;
@@ -650,16 +650,17 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) {
                                /*
                                 * XXX We could preallocate this event.
                                 */
-                               event = isc_event_allocate(manager->mctx,
+                               event = (isc_timerevent_t *)isc_event_allocate(manager->mctx,
                                                           timer,
                                                           type,
                                                           timer->action,
                                                           timer->arg,
                                                           sizeof(*event));
 
-                               if (event != NULL)
+                               if (event != NULL) {
+                                       event->due = timer->due;
                                        isc_task_send(timer->task, &event);
-                               else
+                               else
                                        UNEXPECTED_ERROR(__FILE__, __LINE__,
                                                 isc_msgcat_get(isc_msgcat,
                                                         ISC_MSGSET_TIMER,