]> 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:46 +0000 (05:00 +0000)
committerTatuya JINMEI 神明達哉 <jinmei@isc.org>
Thu, 24 Jul 2008 05:00:46 +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 b18fb847ad95b28edd6af821a7f16c2c4ba90a96..4dfc0d516376d785719513a6cd8149f3ff1d93c9 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 6e78fab3d4f5dab068842a8b076b339e768baeae..602dcf5f9632f37f3ff859356b3a4bf4746a07bc 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resolver.c,v 1.218.2.18.4.77.2.2 2008/07/22 04:16:13 marka Exp $ */
+/* $Id: resolver.c,v 1.218.2.18.4.77.2.3 2008/07/24 05:00:46 jinmei Exp $ */
 
 #include <config.h>
 
@@ -2516,6 +2516,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));
 
@@ -2531,8 +2533,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 3e8d3d593524f0e9820d64806f2dcc2899d6902e..0eae17b2d644ea7c652f31646614feb8a275d5ba 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: timer.h,v 1.28.12.9 2007/08/28 07:19:15 tbox Exp $ */
+/* $Id: timer.h,v 1.28.12.9.4.1 2008/07/24 05:00:46 jinmei Exp $ */
 
 #ifndef ISC_TIMER_H
 #define ISC_TIMER_H 1
@@ -80,6 +80,7 @@
 #include <isc/event.h>
 #include <isc/eventclass.h>
 #include <isc/lang.h>
+#include <isc/time.h>
 
 ISC_LANG_BEGINDECLS
 
@@ -96,6 +97,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 d002b11722ce61261dd8a001de720ac7d874e94e..9eeddcc0383aa2124bc1412b29c0434b1981b343 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: timer.c,v 1.64.12.17 2007/10/24 01:08:01 marka Exp $ */
+/* $Id: timer.c,v 1.64.12.17.4.1 2008/07/24 05:00:46 jinmei Exp $ */
 
 #include <config.h>
 
@@ -578,7 +578,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;
@@ -651,16 +651,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,