2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

merge 4319

This commit is contained in:
Michael Graff
2002-11-12 23:58:14 +00:00
parent 994bc04060
commit e903df2f01
5 changed files with 155 additions and 36 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: request.h,v 1.19 2001/11/30 01:59:27 gson Exp $ */
/* $Id: request.h,v 1.20 2002/11/12 23:58:14 explorer Exp $ */
#ifndef DNS_REQUEST_H
#define DNS_REQUEST_H 1
@@ -204,9 +204,18 @@ isc_result_t
dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, dns_tsigkey_t *key,
unsigned int timeout, unsigned int udpretry,
unsigned int timeout, unsigned int udptimeout,
isc_task_t *task, isc_taskaction_t action, void *arg,
dns_request_t **requestp);
isc_result_t
dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, dns_tsigkey_t *key,
unsigned int timeout, unsigned int udptimeout,
unsigned int udpretries, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp);
/*
* Create and send a request.
*
@@ -215,7 +224,7 @@ dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message,
* 'message' will be rendered and sent to 'address'. If the
* DNS_REQUESTOPT_TCP option is set, TCP will be used. The request
* will timeout after 'timeout' seconds. UDP requests will be resent
* at 'udpretry' intervals if non-zero.
* at 'udptimeout' intervals if non-zero or 'udpretries' is non-zero.
*
* When the request completes, successfully, due to a timeout, or
* because it was canceled, a completion event will be sent to 'task'.
@@ -248,9 +257,17 @@ isc_result_t
dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, unsigned int timeout,
unsigned int udpretry, isc_task_t *task,
unsigned int udptimeout, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp);
isc_result_t
dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, unsigned int timeout,
unsigned int udptimeout, unsigned int udpretries,
isc_task_t *task, isc_taskaction_t action, void *arg,
dns_request_t **requestp);
/*
* Create and send a request.
*
@@ -259,8 +276,8 @@ dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
* 'msgbuf' will be sent to 'destaddr' after setting the id. If the
* DNS_REQUESTOPT_TCP option is set, TCP will be used. The request
* will timeout after 'timeout' seconds. UDP requests will be resent
* at 'udpretry' intervals if non-zero.
*
* at 'udptimeout' intervals if non-zero or if 'udpretries' is not zero.
*
* When the request completes, successfully, due to a timeout, or
* because it was canceled, a completion event will be sent to 'task'.
*

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: request.c,v 1.70 2001/11/30 01:59:16 gson Exp $ */
/* $Id: request.c,v 1.71 2002/11/12 23:58:14 explorer Exp $ */
#include <config.h>
@@ -86,6 +86,7 @@ struct dns_request {
isc_event_t ctlevent;
isc_boolean_t canceling; /* ctlevent outstanding */
isc_sockaddr_t destaddr;
unsigned int udpcount;
};
#define DNS_REQUEST_F_CONNECTING 0x0001
@@ -463,6 +464,7 @@ new_request(isc_mem_t *mctx, dns_request_t **requestp) {
DNS_EVENT_REQUESTCONTROL, do_cancel, request, NULL,
NULL, NULL);
request->canceling = ISC_FALSE;
request->udpcount = 0;
isc_mem_attach(mctx, &request->mctx);
@@ -631,17 +633,37 @@ dns_request_createraw(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
isc_task_t *task, isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
return(dns_request_createraw2(requestmgr, msgbuf, srcaddr, destaddr,
options, timeout, 0, task, action, arg,
requestp));
return(dns_request_createraw3(requestmgr, msgbuf, srcaddr, destaddr,
options, timeout, 0, 0, task, action,
arg, requestp));
}
isc_result_t
dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, unsigned int timeout, unsigned int udpretry, isc_task_t *task,
unsigned int options, unsigned int timeout,
unsigned int udptimeout, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
unsigned int udpretries = 0;
if (udptimeout != 0)
udpretries = timeout / udptimeout;
return (dns_request_createraw3(requestmgr, msgbuf, srcaddr, destaddr,
options, timeout, udptimeout,
udpretries, task, action, arg,
requestp));
}
isc_result_t
dns_request_createraw3(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, unsigned int timeout,
unsigned int udptimeout, unsigned int udpretries,
isc_task_t *task, isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
dns_request_t *request = NULL;
isc_task_t *tclone = NULL;
@@ -674,6 +696,12 @@ dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
if (result != ISC_R_SUCCESS)
return (result);
if (udptimeout == 0 && udpretries != 0) {
udptimeout = timeout / (udpretries + 1);
if (udptimeout == 0)
udptimeout = 1;
}
/*
* Create timer now. We will set it below once.
*/
@@ -745,7 +773,7 @@ dns_request_createraw2(dns_requestmgr_t *requestmgr, isc_buffer_t *msgbuf,
ISC_LIST_APPEND(requestmgr->requests, request, link);
UNLOCK(&requestmgr->lock);
result = set_timer(request->timer, timeout, tcp ? 0 : udpretry);
result = set_timer(request->timer, timeout, tcp ? 0 : udptimeout);
if (result != ISC_R_SUCCESS)
goto unlink;
@@ -789,9 +817,9 @@ dns_request_create(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
return (dns_request_createvia2(requestmgr, message, NULL, address,
options, key, timeout, 0, task, action,
arg, requestp));
return (dns_request_createvia3(requestmgr, message, NULL, address,
options, key, timeout, 0, 0, task,
action, arg, requestp));
}
isc_result_t
@@ -802,18 +830,37 @@ dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
return(dns_request_createvia2(requestmgr, message, srcaddr, destaddr,
options, key, timeout, 0, task, action,
arg, requestp));
return(dns_request_createvia3(requestmgr, message, srcaddr, destaddr,
options, key, timeout, 0, 0, task,
action, arg, requestp));
}
isc_result_t
dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, dns_tsigkey_t *key,
unsigned int timeout, unsigned int udpretry,
unsigned int timeout, unsigned int udptimeout,
isc_task_t *task, isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
unsigned int udpretries = 0;
if (udptimeout != 0)
udpretries = timeout / udptimeout;
return (dns_request_createvia3(requestmgr, message, srcaddr, destaddr,
options, key, timeout, udptimeout,
udpretries, task, action, arg,
requestp));
}
isc_result_t
dns_request_createvia3(dns_requestmgr_t *requestmgr, dns_message_t *message,
isc_sockaddr_t *srcaddr, isc_sockaddr_t *destaddr,
unsigned int options, dns_tsigkey_t *key,
unsigned int timeout, unsigned int udptimeout,
unsigned int udpretries, isc_task_t *task,
isc_taskaction_t action, void *arg,
dns_request_t **requestp)
{
dns_request_t *request = NULL;
isc_task_t *tclone = NULL;
@@ -846,6 +893,12 @@ dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message,
if (result != ISC_R_SUCCESS)
return (result);
if (udptimeout == 0 && udpretries != 0) {
udptimeout = timeout / (udpretries + 1);
if (udptimeout == 0)
udptimeout = 1;
}
/*
* Create timer now. We will set it below once.
*/
@@ -922,7 +975,7 @@ dns_request_createvia2(dns_requestmgr_t *requestmgr, dns_message_t *message,
ISC_LIST_APPEND(requestmgr->requests, request, link);
UNLOCK(&requestmgr->lock);
result = set_timer(request->timer, timeout, tcp ? 0 : udpretry);
result = set_timer(request->timer, timeout, tcp ? 0 : udptimeout);
if (result != ISC_R_SUCCESS)
goto unlink;
@@ -1293,7 +1346,8 @@ req_timeout(isc_task_t *task, isc_event_t *event) {
UNUSED(task);
LOCK(&request->requestmgr->locks[request->hash]);
if (event->ev_type == ISC_TIMEREVENT_TICK) {
if (event->ev_type == ISC_TIMEREVENT_TICK &&
request->udpcount-- != 0) {
if (! DNS_REQUEST_SENDING(request)) {
result = req_send(request, task, &request->destaddr);
if (result != ISC_R_SUCCESS) {