2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-04 00:25:29 +00:00

add dispatcher logging functions

This commit is contained in:
Michael Graff
2000-04-29 00:45:26 +00:00
parent 78eb5a8c85
commit 20c266cbc9
3 changed files with 142 additions and 99 deletions

View File

@@ -21,28 +21,25 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
#include <isc/assertions.h> #include <isc/assertions.h>
#include <isc/error.h> #include <isc/error.h>
#include <isc/lfsr.h> #include <isc/lfsr.h>
#include <isc/log.h>
#include <isc/mem.h> #include <isc/mem.h>
#include <isc/mutex.h> #include <isc/mutex.h>
#include <isc/socket.h> #include <isc/socket.h>
#include <isc/task.h> #include <isc/task.h>
#include <isc/util.h> #include <isc/util.h>
#include <dns/events.h>
#include <dns/types.h>
#include <dns/result.h>
#include <dns/dispatch.h> #include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/log.h>
#include <dns/message.h> #include <dns/message.h>
#include <dns/result.h>
#include <dns/tcpmsg.h> #include <dns/tcpmsg.h>
#include <dns/types.h>
#ifdef DISPATCH_DEBUG
#define XDEBUG(x) printf x
#else
#define XDEBUG(x)
#endif
struct dns_dispentry { struct dns_dispentry {
unsigned int magic; unsigned int magic;
@@ -127,6 +124,74 @@ static dns_dispentry_t *linear_first(dns_dispatch_t *disp);
static dns_dispentry_t *linear_next(dns_dispatch_t *disp, static dns_dispentry_t *linear_next(dns_dispatch_t *disp,
dns_dispentry_t *resp); dns_dispentry_t *resp);
#define LVL(x) \
DNS_LOGCATEGORY_DISPATCH, DNS_LOGMODULE_DISPATCH, \
ISC_LOG_DEBUG(x)
/*
* Format a human-readable representation of the socket address '*sa'
* into the character array 'array', which is of size 'size'.
* The resulting string is guaranteed to be null-terminated.
*/
static void
sockaddr_format(isc_sockaddr_t *sa, char *array, unsigned int size)
{
isc_result_t result;
isc_buffer_t buf;
isc_buffer_init(&buf, array, size);
result = isc_sockaddr_totext(sa, &buf);
if (result != ISC_R_SUCCESS) {
snprintf(array, size,
"<unknown address, family %u>",
sa->type.sa.sa_family);
array[size - 1] = '\0';
}
}
static void
dispatch_log(dns_dispatch_t *disp,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
const char *fmt, ...)
{
char msgbuf[2048];
va_list ap;
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
isc_log_write(dns_lctx, category, module, level,
"dispatch %p: %s", disp, msgbuf);
}
static void
request_log(dns_dispatch_t *disp, dns_dispentry_t *resp,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
const char *fmt, ...)
{
char msgbuf[2048];
char peerbuf[256];
va_list ap;
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
if (VALID_RESPONSE(resp)) {
sockaddr_format(&resp->host, peerbuf, sizeof peerbuf);
isc_log_write(dns_lctx, category, module, level,
"dispatch %p request %p %s: %s", disp, resp,
peerbuf, msgbuf);
} else if (VALID_REQUEST(resp)) {
isc_log_write(dns_lctx, category, module, level,
"dispatch %p response %p: %s", disp, resp,
msgbuf);
} else {
REQUIRE(VALID_REQUEST(resp) || VALID_RESPONSE(resp));
}
}
static void static void
reseed_lfsr(isc_lfsr_t *lfsr, void *arg) reseed_lfsr(isc_lfsr_t *lfsr, void *arg)
{ {
@@ -223,8 +288,9 @@ destroy(dns_dispatch_t *disp)
dns_tcpmsg_invalidate(&disp->tcpmsg); dns_tcpmsg_invalidate(&disp->tcpmsg);
XDEBUG(("dispatch::destroy: detaching from sock %p and task %p\n", dispatch_log(disp, LVL(90),
disp->socket, disp->task)); "shutting down; detaching from sock %p, task %p",
disp->socket, disp->task);
/* /*
* Final cleanup of packets on the request list. * Final cleanup of packets on the request list.
@@ -270,9 +336,6 @@ bucket_search(dns_dispatch_t *disp, isc_sockaddr_t *dest, dns_messageid_t id,
while (res != NULL) { while (res != NULL) {
if ((res->id == id) && isc_sockaddr_equal(dest, &res->host)) if ((res->id == id) && isc_sockaddr_equal(dest, &res->host))
return (res); return (res);
XDEBUG(("lengths (%d, %d), ids (%d, %d)\n",
dest->length, res->host.length,
res->id, id));
res = ISC_LIST_NEXT(res, link); res = ISC_LIST_NEXT(res, link);
} }
@@ -295,10 +358,6 @@ free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len)
isc_mem_put(disp->mctx, buf, len); isc_mem_put(disp->mctx, buf, len);
break; break;
case isc_sockettype_udp: case isc_sockettype_udp:
XDEBUG(("Freeing buffer %p, length %d, into %s, %d remain\n",
buf, len,
(len == disp->buffersize ? "mempool" : "mctx"),
disp->buffers));
if (len == disp->buffersize) if (len == disp->buffersize)
isc_mempool_put(disp->bpool, buf); isc_mempool_put(disp->bpool, buf);
else else
@@ -322,15 +381,9 @@ allocate_buffer(dns_dispatch_t *disp, unsigned int len)
else else
temp = isc_mem_get(disp->mctx, len); temp = isc_mem_get(disp->mctx, len);
if (temp != NULL) { if (temp != NULL)
disp->buffers++; disp->buffers++;
XDEBUG(("Allocated buffer %p, length %d, from %s, %d total\n",
temp, len,
(len == disp->buffersize ? "mempool" : "mctx"),
disp->buffers));
}
return (temp); return (temp);
} }
@@ -340,7 +393,7 @@ free_event(dns_dispatch_t *disp, dns_dispatchevent_t *ev)
if (disp->failsafe_ev == ev) { if (disp->failsafe_ev == ev) {
INSIST(disp->shutdown_out == 1); INSIST(disp->shutdown_out == 1);
disp->shutdown_out = 0; disp->shutdown_out = 0;
XDEBUG(("Returning failsafe event to dispatcher\n"));
return; return;
} }
@@ -398,12 +451,11 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
UNUSED(task); UNUSED(task);
XDEBUG(("Got packet!\n"));
LOCK(&disp->lock); LOCK(&disp->lock);
XDEBUG(("requests: %d, buffers: %d, recvs: %d\n", dispatch_log(disp, LVL(90),
disp->requests, disp->buffers, disp->recvs)); "Got packet: requests %d, buffers %d, recvs %d",
disp->requests, disp->buffers, disp->recvs);
INSIST(disp->recvs > 0); INSIST(disp->recvs > 0);
disp->recvs--; disp->recvs--;
@@ -428,9 +480,6 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
} }
if (ev->result != ISC_R_SUCCESS) { if (ev->result != ISC_R_SUCCESS) {
XDEBUG(("recv result %d (%s)\n", ev->result,
isc_result_totext(ev->result)));
free_buffer(disp, ev->region.base, ev->region.length); free_buffer(disp, ev->region.base, ev->region.length);
/* /*
@@ -449,9 +498,6 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
goto restart; goto restart;
} }
XDEBUG(("length == %d, buflen = %d, addr = %p\n",
ev->n, ev->region.length, ev->region.base));
/* /*
* Peek into the buffer to see what we can see. * Peek into the buffer to see what we can see.
*/ */
@@ -460,14 +506,13 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
dres = dns_message_peekheader(&source, &id, &flags); dres = dns_message_peekheader(&source, &id, &flags);
if (dres != ISC_R_SUCCESS) { if (dres != ISC_R_SUCCESS) {
free_buffer(disp, ev->region.base, ev->region.length); free_buffer(disp, ev->region.base, ev->region.length);
XDEBUG(("dns_message_peekheader(): %s\n", dispatch_log(disp, LVL(10), "Got garbage packet");
isc_result_totext(dres)));
/* XXXMLG log something here... */
goto restart; goto restart;
} }
XDEBUG(("Got valid DNS message header, /QR %c, id %d\n", dispatch_log(disp, LVL(92),
((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id)); "Got valid DNS message header, /QR %c, id %u",
((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id);
/* /*
* Look at flags. If query, check to see if we have someone handling * Look at flags. If query, check to see if we have someone handling
@@ -494,8 +539,9 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
/* response */ /* response */
bucket = disp->methods.hash(disp, &ev->address, id); bucket = disp->methods.hash(disp, &ev->address, id);
resp = bucket_search(disp, &ev->address, id, bucket); resp = bucket_search(disp, &ev->address, id, bucket);
XDEBUG(("Search for response in bucket %d: %s\n", dispatch_log(disp, LVL(90),
bucket, (resp == NULL ? "NOT FOUND" : "FOUND"))); "Search for response in bucket %d: %s",
bucket, (resp == NULL ? "NOT FOUND" : "FOUND"));
if (resp == NULL) { if (resp == NULL) {
free_buffer(disp, ev->region.base, ev->region.length); free_buffer(disp, ev->region.base, ev->region.length);
@@ -529,9 +575,10 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in)
ISC_EVENT_INIT(rev, sizeof(*rev), 0, NULL, ISC_EVENT_INIT(rev, sizeof(*rev), 0, NULL,
DNS_EVENT_DISPATCH, DNS_EVENT_DISPATCH,
resp->action, resp->arg, resp, NULL, NULL); resp->action, resp->arg, resp, NULL, NULL);
XDEBUG(("Sent event %p buffer %p len %d to task %p, resp %p\n", request_log(disp, resp, LVL(90),
rev, rev->buffer.base, rev->buffer.length, "[a] Sent event %p buffer %p len %d to task %p",
resp->task, resp)); rev, rev->buffer.base, rev->buffer.length,
resp->task);
resp->item_out = ISC_TRUE; resp->item_out = ISC_TRUE;
isc_task_send(resp->task, (isc_event_t **)&rev); isc_task_send(resp->task, (isc_event_t **)&rev);
} }
@@ -589,7 +636,9 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in)
REQUIRE(VALID_DISPATCH(disp)); REQUIRE(VALID_DISPATCH(disp));
XDEBUG(("Got TCP packet!\n")); dispatch_log(disp, LVL(90),
"Got TCP packet: requests %d, buffers %d, recvs %d",
disp->requests, disp->buffers, disp->recvs);
LOCK(&disp->lock); LOCK(&disp->lock);
@@ -608,11 +657,12 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in)
break; break;
case ISC_R_EOF: case ISC_R_EOF:
XDEBUG(("Shutting down on EOF\n")); dispatch_log(disp, LVL(90), "Shutting down on EOF");
disp->shutdown_why = ISC_R_EOF; disp->shutdown_why = ISC_R_EOF;
disp->shutting_down = 1; disp->shutting_down = 1;
do_cancel(disp, NULL); do_cancel(disp, NULL);
/* FALLTHROUGH */ /* FALLTHROUGH */
case ISC_R_CANCELED: case ISC_R_CANCELED:
/* /*
* If the recv() was canceled pass the word on. * If the recv() was canceled pass the word on.
@@ -643,23 +693,22 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in)
goto restart; goto restart;
} }
XDEBUG(("result %d, length == %d, addr = %p\n", dispatch_log(disp, LVL(90), "result %d, length == %d, addr = %p",
tcpmsg->result, tcpmsg->result,
tcpmsg->buffer.length, tcpmsg->buffer.base)); tcpmsg->buffer.length, tcpmsg->buffer.base);
/* /*
* Peek into the buffer to see what we can see. * Peek into the buffer to see what we can see.
*/ */
dres = dns_message_peekheader(&tcpmsg->buffer, &id, &flags); dres = dns_message_peekheader(&tcpmsg->buffer, &id, &flags);
if (dres != ISC_R_SUCCESS) { if (dres != ISC_R_SUCCESS) {
XDEBUG(("dns_message_peekheader(): %s\n", dispatch_log(disp, LVL(10), "Got garbage packet");
isc_result_totext(dres)));
/* XXXMLG log something here... */
goto restart; goto restart;
} }
XDEBUG(("Got valid DNS message header, /QR %c, id %d\n", dispatch_log(disp, LVL(92),
((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id)); "Got valid DNS message header, /QR %c, id %u",
((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id);
/* /*
* Allocate an event to send to the query or response client, and * Allocate an event to send to the query or response client, and
@@ -689,8 +738,9 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in)
/* response */ /* response */
bucket = disp->methods.hash(disp, &tcpmsg->address, id); bucket = disp->methods.hash(disp, &tcpmsg->address, id);
resp = bucket_search(disp, &tcpmsg->address, id, bucket); resp = bucket_search(disp, &tcpmsg->address, id, bucket);
XDEBUG(("Search for response in bucket %d: %s\n", dispatch_log(disp, LVL(90),
bucket, (resp == NULL ? "NOT FOUND" : "FOUND"))); "Search for response in bucket %d: %s",
bucket, (resp == NULL ? "NOT FOUND" : "FOUND"));
if (resp == NULL) if (resp == NULL)
goto restart; goto restart;
@@ -717,9 +767,10 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in)
} else { } else {
ISC_EVENT_INIT(rev, sizeof(*rev), 0, NULL, DNS_EVENT_DISPATCH, ISC_EVENT_INIT(rev, sizeof(*rev), 0, NULL, DNS_EVENT_DISPATCH,
resp->action, resp->arg, resp, NULL, NULL); resp->action, resp->arg, resp, NULL, NULL);
XDEBUG(("Sent event %p buffer %p len %d to task %p, resp %p\n", request_log(disp, resp, LVL(90),
rev, rev->buffer.base, rev->buffer.length, "[b] Sent event %p buffer %p len %d to task %p",
resp->task, resp)); rev, rev->buffer.base, rev->buffer.length,
resp->task);
resp->item_out = ISC_TRUE; resp->item_out = ISC_TRUE;
isc_task_send(resp->task, (isc_event_t **)&rev); isc_task_send(resp->task, (isc_event_t **)&rev);
} }
@@ -771,8 +822,6 @@ startrecv(dns_dispatch_t *disp)
region.base = allocate_buffer(disp, disp->buffersize); region.base = allocate_buffer(disp, disp->buffersize);
if (region.base == NULL) if (region.base == NULL)
return; return;
XDEBUG(("Recv into %p, length %d\n", region.base,
region.length));
res = isc_socket_recv(disp->socket, &region, 1, res = isc_socket_recv(disp->socket, &region, 1,
disp->task, udp_recv, disp); disp->task, udp_recv, disp);
if (res != ISC_R_SUCCESS) { if (res != ISC_R_SUCCESS) {
@@ -785,7 +834,6 @@ startrecv(dns_dispatch_t *disp)
break; break;
case isc_sockettype_tcp: case isc_sockettype_tcp:
XDEBUG(("Starting tcp receive\n"));
res = dns_tcpmsg_readmessage(&disp->tcpmsg, res = dns_tcpmsg_readmessage(&disp->tcpmsg,
disp->task, tcp_recv, disp->task, tcp_recv,
disp); disp);
@@ -947,11 +995,10 @@ dns_dispatch_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
disp->task = NULL; disp->task = NULL;
isc_task_attach(task, &disp->task); isc_task_attach(task, &disp->task);
XDEBUG(("dns_dispatch_create: attaching to task %p\n", disp->task)); dispatch_log(disp, LVL(90), "attaching to task %p", disp->task);
disp->socket = NULL; disp->socket = NULL;
isc_socket_attach(sock, &disp->socket); isc_socket_attach(sock, &disp->socket);
XDEBUG(("dns_dispatch_create: attaching to socket %p\n", dispatch_log(disp, LVL(90), "attaching to socket %p", disp->socket);
disp->socket));
dns_tcpmsg_init(disp->mctx, disp->socket, &disp->tcpmsg); dns_tcpmsg_init(disp->mctx, disp->socket, &disp->tcpmsg);
@@ -1014,7 +1061,7 @@ dns_dispatch_detach(dns_dispatch_t **dispp)
killit = ISC_TRUE; killit = ISC_TRUE;
} }
XDEBUG(("dns_dispatch_detach: refcount = %d\n", disp->refcount)); dispatch_log(disp, LVL(90), "detach: refcount %d", disp->refcount);
UNLOCK(&disp->lock); UNLOCK(&disp->lock);
@@ -1082,9 +1129,6 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, isc_sockaddr_t *dest,
disp->requests++; disp->requests++;
res->task = NULL; res->task = NULL;
isc_task_attach(task, &res->task); isc_task_attach(task, &res->task);
XDEBUG(("dns_dispatch_addresponse: attaching to task %p\n",
res->task));
res->magic = RESPONSE_MAGIC; res->magic = RESPONSE_MAGIC;
res->id = id; res->id = id;
res->bucket = bucket; res->bucket = bucket;
@@ -1096,7 +1140,8 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, isc_sockaddr_t *dest,
ISC_LINK_INIT(res, link); ISC_LINK_INIT(res, link);
ISC_LIST_APPEND(disp->qid_table[bucket], res, link); ISC_LIST_APPEND(disp->qid_table[bucket], res, link);
XDEBUG(("Inserted response into bucket %d\n", bucket)); request_log(disp, res, LVL(90),
"attached to task %p", res->task);
startrecv(disp); startrecv(disp);
@@ -1149,7 +1194,6 @@ dns_dispatch_removeresponse(dns_dispatch_t *disp, dns_dispentry_t **resp,
killit = ISC_TRUE; killit = ISC_TRUE;
} }
res->magic = 0;
bucket = res->bucket; bucket = res->bucket;
ISC_LIST_UNLINK(disp->qid_table[bucket], res, link); ISC_LIST_UNLINK(disp->qid_table[bucket], res, link);
@@ -1177,8 +1221,7 @@ dns_dispatch_removeresponse(dns_dispatch_t *disp, dns_dispentry_t **resp,
free_event(disp, ev); free_event(disp, ev);
} }
XDEBUG(("dns_dispatch_removeresponse: detaching from task %p\n", request_log(disp, res, LVL(90), "detaching from task %p", res->task);
res->task));
isc_task_detach(&res->task); isc_task_detach(&res->task);
/* /*
@@ -1192,6 +1235,7 @@ dns_dispatch_removeresponse(dns_dispatch_t *disp, dns_dispentry_t **resp,
free_event(disp, ev); free_event(disp, ev);
ev = ISC_LIST_HEAD(res->items); ev = ISC_LIST_HEAD(res->items);
} }
res->magic = 0;
isc_mempool_put(disp->rpool, res); isc_mempool_put(disp->rpool, res);
if (disp->shutting_down == 1) if (disp->shutting_down == 1)
do_cancel(disp, NULL); do_cancel(disp, NULL);
@@ -1237,8 +1281,6 @@ dns_dispatch_addrequest(dns_dispatch_t *disp,
disp->requests++; disp->requests++;
res->task = NULL; res->task = NULL;
isc_task_attach(task, &res->task); isc_task_attach(task, &res->task);
XDEBUG(("dns_dispatch_addrequest: attaching to task %p\n",
res->task));
res->magic = REQUEST_MAGIC; res->magic = REQUEST_MAGIC;
res->bucket = INVALID_BUCKET; res->bucket = INVALID_BUCKET;
@@ -1249,6 +1291,8 @@ dns_dispatch_addrequest(dns_dispatch_t *disp,
ISC_LINK_INIT(res, link); ISC_LINK_INIT(res, link);
ISC_LIST_APPEND(disp->rq_handlers, res, link); ISC_LIST_APPEND(disp->rq_handlers, res, link);
request_log(disp, res, LVL(90), "attaching task %p", res->task);
/* /*
* If there are queries waiting to be processed, give this critter * If there are queries waiting to be processed, give this critter
* one of them. * one of them.
@@ -1304,8 +1348,6 @@ dns_dispatch_removerequest(dns_dispatch_t *disp, dns_dispentry_t **resp,
killit = ISC_TRUE; killit = ISC_TRUE;
} }
res->magic = 0;
ISC_LIST_UNLINK(disp->rq_handlers, res, link); ISC_LIST_UNLINK(disp->rq_handlers, res, link);
if (ev == NULL && res->item_out) { if (ev == NULL && res->item_out) {
@@ -1331,10 +1373,10 @@ dns_dispatch_removerequest(dns_dispatch_t *disp, dns_dispentry_t **resp,
free_event(disp, ev); free_event(disp, ev);
} }
XDEBUG(("dns_dispatch_removerequest: detaching from task %p\n", request_log(disp, res, LVL(90), "detaching from task %p", res->task);
res->task));
isc_task_detach(&res->task); isc_task_detach(&res->task);
res->magic = 0;
isc_mempool_put(disp->rpool, res); isc_mempool_put(disp->rpool, res);
if (disp->shutting_down == 1) if (disp->shutting_down == 1)
do_cancel(disp, NULL); do_cancel(disp, NULL);
@@ -1407,8 +1449,10 @@ do_next_response(dns_dispatch_t *disp, dns_dispentry_t *resp)
ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, DNS_EVENT_DISPATCH, ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, DNS_EVENT_DISPATCH,
resp->action, resp->arg, resp, NULL, NULL); resp->action, resp->arg, resp, NULL, NULL);
resp->item_out = ISC_TRUE; resp->item_out = ISC_TRUE;
XDEBUG(("Sent event %p for buffer %p (len %d) to task %p, resp %p\n", request_log(disp, resp, LVL(90),
ev, ev->buffer.base, ev->buffer.length, resp->task, resp)); "[c] Sent event %p buffer %p len %d to task %p",
ev, ev->buffer.base, ev->buffer.length,
resp->task);
isc_task_send(resp->task, (isc_event_t **)&ev); isc_task_send(resp->task, (isc_event_t **)&ev);
} }
@@ -1431,8 +1475,9 @@ do_next_request(dns_dispatch_t *disp, dns_dispentry_t *resp)
ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, DNS_EVENT_DISPATCH, ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, DNS_EVENT_DISPATCH,
resp->action, resp->arg, resp, NULL, NULL); resp->action, resp->arg, resp, NULL, NULL);
resp->item_out = ISC_TRUE; resp->item_out = ISC_TRUE;
XDEBUG(("Sent event %p for buffer %p (len %d) to task %p, resp %p\n", request_log(disp, resp, LVL(90),
ev, ev->buffer.base, ev->buffer.length, resp->task, resp)); "[d] Sent event %p buffer %p len %d to task %p",
ev, ev->buffer.base, ev->buffer.length, resp->task);
isc_task_send(resp->task, (isc_event_t **)&ev); isc_task_send(resp->task, (isc_event_t **)&ev);
} }
@@ -1441,11 +1486,10 @@ do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp)
{ {
dns_dispatchevent_t *ev; dns_dispatchevent_t *ev;
if (disp->shutdown_out == 1) { if (disp->shutdown_out == 1)
XDEBUG(("do_cancel() call ignored\n"));
return; return;
}
XDEBUG(("do_cancel: disp = %p, resp = %p\n", disp, resp)); request_log(disp, resp, LVL(90), "cancel");
/* /*
* If no target given, find the first request handler. If * If no target given, find the first request handler. If
@@ -1453,14 +1497,9 @@ do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp)
* kill them. * kill them.
*/ */
if (resp == NULL) { if (resp == NULL) {
XDEBUG(("do_cancel: passed a NULL response, searching...\n"));
if (ISC_LIST_EMPTY(disp->rq_events)) { if (ISC_LIST_EMPTY(disp->rq_events)) {
XDEBUG(("do_cancel: non-empty request list.\n"));
resp = ISC_LIST_HEAD(disp->rq_handlers); resp = ISC_LIST_HEAD(disp->rq_handlers);
while (resp != NULL) { while (resp != NULL) {
XDEBUG(("do_cancel: resp %p, item_out %s\n",
resp,
(resp->item_out ? "TRUE" : "FALSE")));
if (resp->item_out == ISC_FALSE) if (resp->item_out == ISC_FALSE)
break; break;
resp = ISC_LIST_NEXT(resp, link); resp = ISC_LIST_NEXT(resp, link);
@@ -1499,8 +1538,8 @@ do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp)
ev->buffer.base = NULL; ev->buffer.base = NULL;
ev->buffer.length = 0; ev->buffer.length = 0;
disp->shutdown_out = 1; disp->shutdown_out = 1;
XDEBUG(("Sending failsafe event %p to task %p, resp %p\n", request_log(disp, resp, LVL(10),
ev, resp->task, resp)); "sent failsafe event %p to task %p", ev, resp->task);
resp->item_out = ISC_TRUE; resp->item_out = ISC_TRUE;
isc_task_send(resp->task, (isc_event_t **)&ev); isc_task_send(resp->task, (isc_event_t **)&ev);
} }

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: log.h,v 1.14 2000/04/11 18:17:35 gson Exp $ */ /* $Id: log.h,v 1.15 2000/04/29 00:45:26 explorer Exp $ */
/* Principal Authors: DCL */ /* Principal Authors: DCL */
@@ -40,7 +40,7 @@ extern isc_logmodule_t dns_modules[];
#define DNS_LOGCATEGORY_RESOLVER (&dns_categories[5]) #define DNS_LOGCATEGORY_RESOLVER (&dns_categories[5])
#define DNS_LOGCATEGORY_XFER_IN (&dns_categories[6]) #define DNS_LOGCATEGORY_XFER_IN (&dns_categories[6])
#define DNS_LOGCATEGORY_XFER_OUT (&dns_categories[7]) #define DNS_LOGCATEGORY_XFER_OUT (&dns_categories[7])
#define DNS_LOGCATEGORY_DISPATCH (&dns_categories[8])
/* Backwards compatibility. */ /* Backwards compatibility. */
#define DNS_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL #define DNS_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL
@@ -62,6 +62,8 @@ extern isc_logmodule_t dns_modules[];
#define DNS_LOGMODULE_XFER_OUT (&dns_modules[14]) #define DNS_LOGMODULE_XFER_OUT (&dns_modules[14])
#define DNS_LOGMODULE_ACL (&dns_modules[15]) #define DNS_LOGMODULE_ACL (&dns_modules[15])
#define DNS_LOGMODULE_VALIDATOR (&dns_modules[16]) #define DNS_LOGMODULE_VALIDATOR (&dns_modules[16])
#define DNS_LOGMODULE_DISPATCH (&dns_modules[17])
void void
dns_log_init(isc_log_t *lctx); dns_log_init(isc_log_t *lctx);
/* /*

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: log.c,v 1.18 2000/04/28 02:08:00 tale Exp $ */ /* $Id: log.c,v 1.19 2000/04/29 00:45:24 explorer Exp $ */
/* Principal Authors: DCL */ /* Principal Authors: DCL */
@@ -42,6 +42,7 @@ isc_logcategory_t dns_categories[] = {
{ "resolver", 0 }, { "resolver", 0 },
{ "xfer-in", 0 }, { "xfer-in", 0 },
{ "xfer-out", 0 }, { "xfer-out", 0 },
{ "dispatch", 0 },
{ NULL, 0 } { NULL, 0 }
}; };
@@ -67,6 +68,7 @@ isc_logmodule_t dns_modules[] = {
{ "dns/xfrout", 0 }, { "dns/xfrout", 0 },
{ "dns/acl", 0 }, { "dns/acl", 0 },
{ "dns/validator", 0 }, { "dns/validator", 0 },
{ "dns/dispatch", 0 },
{ NULL, 0 } { NULL, 0 }
}; };