2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 23:55:27 +00:00

Don't create a timer for every incoming query - only create it for updates,

notifies, and recursive queries.
This commit is contained in:
Brian Wellington
2001-01-29 19:49:52 +00:00
parent 1718abab45
commit 3d76b54512
4 changed files with 29 additions and 11 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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> #include <config.h>
@@ -279,14 +279,15 @@ client_free(ns_client_t *client) {
clientmgr_destroy(manager); clientmgr_destroy(manager);
} }
static void void
set_timeout(ns_client_t *client, unsigned int seconds) { ns_client_settimeout(ns_client_t *client, unsigned int seconds) {
isc_result_t result; isc_result_t result;
isc_interval_t interval; isc_interval_t interval;
isc_interval_set(&interval, seconds, 0); isc_interval_set(&interval, seconds, 0);
result = isc_timer_reset(client->timer, isc_timertype_once, NULL, result = isc_timer_reset(client->timer, isc_timertype_once, NULL,
&interval, ISC_FALSE); &interval, ISC_FALSE);
client->timerset = ISC_TRUE;
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
ns_client_log(client, NS_LOGCATEGORY_CLIENT, ns_client_log(client, NS_LOGCATEGORY_CLIENT,
NS_LOGMODULE_CLIENT, ISC_LOG_ERROR, NS_LOGMODULE_CLIENT, ISC_LOG_ERROR,
@@ -389,8 +390,12 @@ exit_check(ns_client_t *client) {
if (client->tcpquota != NULL) if (client->tcpquota != NULL)
isc_quota_detach(&client->tcpquota); isc_quota_detach(&client->tcpquota);
(void) isc_timer_reset(client->timer, isc_timertype_inactive, if (client->timerset) {
NULL, NULL, ISC_TRUE); (void) isc_timer_reset(client->timer,
isc_timertype_inactive,
NULL, NULL, ISC_TRUE);
client->timerset = ISC_FALSE;
}
client->peeraddr_valid = 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); isc_stdtime_get(&client->requesttime);
client->now = client->requesttime; client->now = client->requesttime;
set_timeout(client, 60);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
if (TCP_CLIENT(client)) if (TCP_CLIENT(client))
ns_client_next(client, result); ns_client_next(client, result);
@@ -1436,10 +1439,12 @@ client_request(isc_task_t *task, isc_event_t *event) {
break; break;
case dns_opcode_update: case dns_opcode_update:
CTRACE("update"); CTRACE("update");
ns_client_settimeout(client, 60);
ns_update_start(client, sigresult); ns_update_start(client, sigresult);
break; break;
case dns_opcode_notify: case dns_opcode_notify:
CTRACE("notify"); CTRACE("notify");
ns_client_settimeout(client, 60);
ns_notify_start(client); ns_notify_start(client);
break; break;
case dns_opcode_iquery: case dns_opcode_iquery:
@@ -1523,6 +1528,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp)
client, &client->timer); client, &client->timer);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto cleanup_task; goto cleanup_task;
client->timerset = ISC_FALSE;
client->message = NULL; client->message = NULL;
result = dns_message_create(manager->mctx, DNS_MESSAGE_INTENTPARSE, 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 * Set a timeout to limit the amount of time we will wait
* for a request on this TCP connection. * for a request on this TCP connection.
*/ */
set_timeout(client, 30); ns_client_settimeout(client, 30);
client->state = client->newstate = NS_CLIENTSTATE_READING; client->state = client->newstate = NS_CLIENTSTATE_READING;
INSIST(client->nreads == 0); INSIST(client->nreads == 0);

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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 #ifndef NAMED_CLIENT_H
#define NAMED_CLIENT_H 1 #define NAMED_CLIENT_H 1
@@ -107,6 +107,7 @@ struct ns_client {
dns_tcpmsg_t tcpmsg; dns_tcpmsg_t tcpmsg;
isc_boolean_t tcpmsg_valid; isc_boolean_t tcpmsg_valid;
isc_timer_t * timer; isc_timer_t * timer;
isc_boolean_t timerset;
dns_message_t * message; dns_message_t * message;
unsigned char * sendbuf; unsigned char * sendbuf;
unsigned char * recvbuf; unsigned char * recvbuf;
@@ -220,6 +221,12 @@ ns_client_replace(ns_client_t *client);
* leaving the dispatch/socket without service. * 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 isc_result_t
ns_clientmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, ns_clientmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, ns_clientmgr_t **managerp); isc_timermgr_t *timermgr, ns_clientmgr_t **managerp);

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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 #ifndef NAMED_QUERY_H
#define NAMED_QUERY_H 1 #define NAMED_QUERY_H 1
@@ -39,6 +39,7 @@ typedef struct ns_dbversion {
struct ns_query { struct ns_query {
unsigned int attributes; unsigned int attributes;
unsigned int restarts; unsigned int restarts;
isc_boolean_t timerset;
dns_name_t * qname; dns_name_t * qname;
dns_name_t * origqname; dns_name_t * origqname;
unsigned int dboptions; unsigned int dboptions;

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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> #include <config.h>
@@ -239,6 +239,7 @@ query_reset(ns_client_t *client, isc_boolean_t everything) {
client->query.attributes = (NS_QUERYATTR_RECURSIONOK | client->query.attributes = (NS_QUERYATTR_RECURSIONOK |
NS_QUERYATTR_CACHEOK); NS_QUERYATTR_CACHEOK);
client->query.restarts = 0; client->query.restarts = 0;
client->query.timerset = ISC_FALSE;
client->query.origqname = NULL; client->query.origqname = NULL;
client->query.qname = NULL; client->query.qname = NULL;
client->query.dboptions = 0; 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.activeversions);
ISC_LIST_INIT(client->query.freeversions); ISC_LIST_INIT(client->query.freeversions);
client->query.restarts = 0; client->query.restarts = 0;
client->query.timerset = ISC_FALSE;
client->query.qname = NULL; client->query.qname = NULL;
client->query.fetch = NULL; client->query.fetch = NULL;
client->query.authdb = NULL; client->query.authdb = NULL;
@@ -2097,6 +2099,8 @@ query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qdomain,
} else } else
sigrdataset = NULL; sigrdataset = NULL;
if (client->query.timerset == ISC_FALSE)
ns_client_settimeout(client, 60);
result = dns_resolver_createfetch(client->view->resolver, result = dns_resolver_createfetch(client->view->resolver,
client->query.qname, client->query.qname,
qtype, qdomain, nameservers, qtype, qdomain, nameservers,