mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +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:
@@ -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,
|
||||
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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user