]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't create a timer for every incoming query - only create it for updates,
authorBrian Wellington <source@isc.org>
Mon, 29 Jan 2001 19:49:52 +0000 (19:49 +0000)
committerBrian Wellington <source@isc.org>
Mon, 29 Jan 2001 19:49:52 +0000 (19:49 +0000)
notifies, and recursive queries.

bin/named/client.c
bin/named/include/named/client.h
bin/named/include/named/query.h
bin/named/query.c

index 0935024f7fbc75c585deaf404ed212c74b291abe..d28023b7fcab228f4999133e3299c01513cda2e3 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: client.c,v 1.142 2001/01/27 02:07:59 bwelling Exp $ */
+/* $Id: client.c,v 1.143 2001/01/29 19:49:48 bwelling Exp $ */
 
 #include <config.h>
 
@@ -279,14 +279,15 @@ client_free(ns_client_t *client) {
                clientmgr_destroy(manager);
 }
 
-static void
-set_timeout(ns_client_t *client, unsigned int seconds) {
+void
+ns_client_settimeout(ns_client_t *client, unsigned int seconds) {
        isc_result_t result;
        isc_interval_t interval;
 
        isc_interval_set(&interval, seconds, 0);
        result = isc_timer_reset(client->timer, isc_timertype_once, NULL,
                                 &interval, ISC_FALSE);
+       client->timerset = ISC_TRUE;
        if (result != ISC_R_SUCCESS) {
                ns_client_log(client, NS_LOGCATEGORY_CLIENT,
                              NS_LOGMODULE_CLIENT, ISC_LOG_ERROR,
@@ -389,8 +390,12 @@ exit_check(ns_client_t *client) {
                if (client->tcpquota != NULL)
                        isc_quota_detach(&client->tcpquota);
 
-               (void) isc_timer_reset(client->timer, isc_timertype_inactive,
-                                      NULL, NULL, ISC_TRUE);
+               if (client->timerset) {
+                       (void) isc_timer_reset(client->timer,
+                                              isc_timertype_inactive,
+                                              NULL, NULL, ISC_TRUE);
+                       client->timerset = ISC_FALSE;
+               }
 
                client->peeraddr_valid = ISC_FALSE;
 
@@ -1189,8 +1194,6 @@ client_request(isc_task_t *task, isc_event_t *event) {
        isc_stdtime_get(&client->requesttime);
        client->now = client->requesttime;
 
-       set_timeout(client, 60);
-
        if (result != ISC_R_SUCCESS) {
                if (TCP_CLIENT(client))
                        ns_client_next(client, result);
@@ -1436,10 +1439,12 @@ client_request(isc_task_t *task, isc_event_t *event) {
                break;
        case dns_opcode_update:
                CTRACE("update");
+               ns_client_settimeout(client, 60);
                ns_update_start(client, sigresult);
                break;
        case dns_opcode_notify:
                CTRACE("notify");
+               ns_client_settimeout(client, 60);
                ns_notify_start(client);
                break;
        case dns_opcode_iquery:
@@ -1523,6 +1528,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
                                  client, &client->timer);
        if (result != ISC_R_SUCCESS)
                goto cleanup_task;
+       client->timerset = ISC_FALSE;
 
        client->message = NULL;
        result = dns_message_create(manager->mctx, DNS_MESSAGE_INTENTPARSE,
@@ -1633,7 +1639,7 @@ client_read(ns_client_t *client) {
         * Set a timeout to limit the amount of time we will wait
         * for a request on this TCP connection.
         */
-       set_timeout(client, 30);
+       ns_client_settimeout(client, 30);
 
        client->state = client->newstate = NS_CLIENTSTATE_READING;
        INSIST(client->nreads == 0);
index 62ba9ffbe98692b515f655243d39915925f5a3d3..30456c1085de26d26f6021bc528e80820ac55814 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: client.h,v 1.50 2001/01/27 02:08:03 bwelling Exp $ */
+/* $Id: client.h,v 1.51 2001/01/29 19:49:51 bwelling Exp $ */
 
 #ifndef NAMED_CLIENT_H
 #define NAMED_CLIENT_H 1
@@ -107,6 +107,7 @@ struct ns_client {
        dns_tcpmsg_t            tcpmsg;
        isc_boolean_t           tcpmsg_valid;
        isc_timer_t *           timer;
+       isc_boolean_t           timerset;
        dns_message_t *         message;
        unsigned char *         sendbuf;
        unsigned char *         recvbuf;
@@ -220,6 +221,12 @@ ns_client_replace(ns_client_t *client);
  * leaving the dispatch/socket without service.
  */
 
+void
+ns_client_settimeout(ns_client_t *client, unsigned int seconds);
+/*
+ * Set a timer in the client to go off in the specified amount of time.
+ */
+
 isc_result_t
 ns_clientmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
                    isc_timermgr_t *timermgr, ns_clientmgr_t **managerp);
index 996cc66ab9b008e24bcd3459e0addfff1b9a8f5e..001d5d9e9f12b1d1b9e4b190e4a3c06faf99da4d 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: query.h,v 1.26 2001/01/09 21:40:27 bwelling Exp $ */
+/* $Id: query.h,v 1.27 2001/01/29 19:49:52 bwelling Exp $ */
 
 #ifndef NAMED_QUERY_H
 #define NAMED_QUERY_H 1
@@ -39,6 +39,7 @@ typedef struct ns_dbversion {
 struct ns_query {
        unsigned int                    attributes;
        unsigned int                    restarts;
+       isc_boolean_t                   timerset;
        dns_name_t *                    qname;
        dns_name_t *                    origqname;
        unsigned int                    dboptions;
index ea63f4ab5c61199feba640c338ff26cdf5ae015e..3a3cce296465d28f506c48198bed2a47b8a53556 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: query.c,v 1.177 2001/01/26 23:40:44 gson Exp $ */
+/* $Id: query.c,v 1.178 2001/01/29 19:49:50 bwelling Exp $ */
 
 #include <config.h>
 
@@ -239,6 +239,7 @@ query_reset(ns_client_t *client, isc_boolean_t everything) {
        client->query.attributes = (NS_QUERYATTR_RECURSIONOK |
                                    NS_QUERYATTR_CACHEOK);
        client->query.restarts = 0;
+       client->query.timerset = ISC_FALSE;
        client->query.origqname = NULL;
        client->query.qname = NULL;
        client->query.dboptions = 0;
@@ -467,6 +468,7 @@ ns_query_init(ns_client_t *client) {
        ISC_LIST_INIT(client->query.activeversions);
        ISC_LIST_INIT(client->query.freeversions);
        client->query.restarts = 0;
+       client->query.timerset = ISC_FALSE;
        client->query.qname = NULL;
        client->query.fetch = NULL;
        client->query.authdb = NULL;
@@ -2097,6 +2099,8 @@ query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qdomain,
        } else
                sigrdataset = NULL;
 
+       if (client->query.timerset == ISC_FALSE)
+               ns_client_settimeout(client, 60);
        result = dns_resolver_createfetch(client->view->resolver,
                                          client->query.qname,
                                          qtype, qdomain, nameservers,