mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
more request shutdown logic fixes from Mark
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: request.c,v 1.44 2000/12/19 03:36:48 marka Exp $ */
|
/* $Id: request.c,v 1.45 2000/12/22 19:39:01 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -88,14 +88,14 @@ struct dns_request {
|
|||||||
|
|
||||||
#define DNS_REQUEST_F_CONNECTING 0x0001
|
#define DNS_REQUEST_F_CONNECTING 0x0001
|
||||||
#define DNS_REQUEST_F_CANCELED 0x0002
|
#define DNS_REQUEST_F_CANCELED 0x0002
|
||||||
#define DNS_REQUEST_F_DESTROYED 0x0004 /* dns_request_destroy() called */
|
#define DNS_REQUEST_F_TIMEDOUT 0x0004 /* cancelled due to a timeout */
|
||||||
#define DNS_REQUEST_F_TCP 0x0008 /* This request used TCP */
|
#define DNS_REQUEST_F_TCP 0x0008 /* This request used TCP */
|
||||||
#define DNS_REQUEST_CANCELED(r) \
|
#define DNS_REQUEST_CANCELED(r) \
|
||||||
(((r)->flags & DNS_REQUEST_F_CANCELED) != 0)
|
(((r)->flags & DNS_REQUEST_F_CANCELED) != 0)
|
||||||
#define DNS_REQUEST_CONNECTING(r) \
|
#define DNS_REQUEST_CONNECTING(r) \
|
||||||
(((r)->flags & DNS_REQUEST_F_CONNECTING) != 0)
|
(((r)->flags & DNS_REQUEST_F_CONNECTING) != 0)
|
||||||
#define DNS_REQUEST_DESTROYED(r) \
|
#define DNS_REQUEST_TIMEDOUT(r) \
|
||||||
(((r)->flags & DNS_REQUEST_F_DESTROYED) != 0)
|
(((r)->flags & DNS_REQUEST_F_TIMEDOUT) != 0)
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -1107,7 +1107,8 @@ dns_request_cancel(dns_request_t *request) {
|
|||||||
LOCK(&request->requestmgr->locks[request->hash]);
|
LOCK(&request->requestmgr->locks[request->hash]);
|
||||||
if (!DNS_REQUEST_CANCELED(request)) {
|
if (!DNS_REQUEST_CANCELED(request)) {
|
||||||
req_cancel(request);
|
req_cancel(request);
|
||||||
req_sendevent(request, ISC_R_CANCELED);
|
if (!DNS_REQUEST_CONNECTING(request))
|
||||||
|
req_sendevent(request, ISC_R_CANCELED);
|
||||||
}
|
}
|
||||||
UNLOCK(&request->requestmgr->locks[request->hash]);
|
UNLOCK(&request->requestmgr->locks[request->hash]);
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
@@ -1145,7 +1146,6 @@ dns_request_usedtcp(dns_request_t *request) {
|
|||||||
void
|
void
|
||||||
dns_request_destroy(dns_request_t **requestp) {
|
dns_request_destroy(dns_request_t **requestp) {
|
||||||
dns_request_t *request;
|
dns_request_t *request;
|
||||||
isc_boolean_t need_destroy = ISC_FALSE;
|
|
||||||
|
|
||||||
REQUIRE(requestp != NULL && VALID_REQUEST(*requestp));
|
REQUIRE(requestp != NULL && VALID_REQUEST(*requestp));
|
||||||
|
|
||||||
@@ -1157,13 +1157,10 @@ dns_request_destroy(dns_request_t **requestp) {
|
|||||||
LOCK(&request->requestmgr->lock);
|
LOCK(&request->requestmgr->lock);
|
||||||
ISC_LIST_UNLINK(request->requestmgr->requests, request, link);
|
ISC_LIST_UNLINK(request->requestmgr->requests, request, link);
|
||||||
UNLOCK(&request->requestmgr->lock);
|
UNLOCK(&request->requestmgr->lock);
|
||||||
if (!DNS_REQUEST_CONNECTING(request))
|
INSIST(!DNS_REQUEST_CONNECTING(request));
|
||||||
need_destroy = ISC_TRUE;
|
|
||||||
request->flags |= DNS_REQUEST_F_DESTROYED;
|
|
||||||
UNLOCK(&request->requestmgr->locks[request->hash]);
|
UNLOCK(&request->requestmgr->locks[request->hash]);
|
||||||
|
|
||||||
if (need_destroy)
|
req_destroy(request);
|
||||||
req_destroy(request);
|
|
||||||
|
|
||||||
*requestp = NULL;
|
*requestp = NULL;
|
||||||
}
|
}
|
||||||
@@ -1177,7 +1174,6 @@ req_connected(isc_task_t *task, isc_event_t *event) {
|
|||||||
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_request_t *request = event->ev_arg;
|
dns_request_t *request = event->ev_arg;
|
||||||
isc_boolean_t need_destroy = ISC_FALSE;
|
|
||||||
|
|
||||||
REQUIRE(event->ev_type == ISC_SOCKEVENT_CONNECT);
|
REQUIRE(event->ev_type == ISC_SOCKEVENT_CONNECT);
|
||||||
REQUIRE(VALID_REQUEST(request));
|
REQUIRE(VALID_REQUEST(request));
|
||||||
@@ -1189,8 +1185,13 @@ req_connected(isc_task_t *task, isc_event_t *event) {
|
|||||||
request->flags &= ~DNS_REQUEST_F_CONNECTING;
|
request->flags &= ~DNS_REQUEST_F_CONNECTING;
|
||||||
|
|
||||||
if (DNS_REQUEST_CANCELED(request)) {
|
if (DNS_REQUEST_CANCELED(request)) {
|
||||||
if (DNS_REQUEST_DESTROYED(request))
|
/*
|
||||||
need_destroy = ISC_TRUE;
|
* Send delayed event.
|
||||||
|
*/
|
||||||
|
if (DNS_REQUEST_TIMEDOUT(request))
|
||||||
|
req_sendevent(request, ISC_R_TIMEDOUT);
|
||||||
|
else
|
||||||
|
req_sendevent(request, ISC_R_CANCELED);
|
||||||
} else {
|
} else {
|
||||||
dns_dispatch_starttcp(request->dispatch);
|
dns_dispatch_starttcp(request->dispatch);
|
||||||
result = sevent->result;
|
result = sevent->result;
|
||||||
@@ -1203,8 +1204,6 @@ req_connected(isc_task_t *task, isc_event_t *event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNLOCK(&request->requestmgr->locks[request->hash]);
|
UNLOCK(&request->requestmgr->locks[request->hash]);
|
||||||
if (need_destroy)
|
|
||||||
req_destroy(request);
|
|
||||||
isc_event_free(&event);
|
isc_event_free(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1280,8 +1279,10 @@ req_timeout(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
UNUSED(task);
|
UNUSED(task);
|
||||||
LOCK(&request->requestmgr->locks[request->hash]);
|
LOCK(&request->requestmgr->locks[request->hash]);
|
||||||
|
request->flags |= DNS_REQUEST_F_TIMEDOUT;
|
||||||
req_cancel(request);
|
req_cancel(request);
|
||||||
req_sendevent(request, ISC_R_TIMEDOUT);
|
if (!DNS_REQUEST_CONNECTING(request))
|
||||||
|
req_sendevent(request, ISC_R_TIMEDOUT);
|
||||||
UNLOCK(&request->requestmgr->locks[request->hash]);
|
UNLOCK(&request->requestmgr->locks[request->hash]);
|
||||||
isc_event_free(&event);
|
isc_event_free(&event);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user