* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dispatch.c,v 1.109 2002/07/29 01:03:24 marka Exp $ */
+/* $Id: dispatch.c,v 1.110 2002/09/04 02:26:12 jinmei Exp $ */
#include <config.h>
*
* If I/O result == CANCELED or error, free the buffer.
*
- * If query:
- * if no listeners: free the buffer, restart.
- * if listener: allocate event, fill in details.
- * If cannot allocate, free buffer, restart.
- * if rq event queue is not empty, queue. else, send.
- * restart.
+ * If query, free the buffer, restart.
*
* If response:
* Allocate event, fill in details.
"got packet: requests %d, buffers %d, recvs %d",
disp->requests, disp->mgr->buffers, disp->recv_pending);
- if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) == 0) {
+ if (ev->ev_type == ISC_SOCKEVENT_RECVDONE) {
+ /*
+ * Unless the receive event was imported from a listening
+ * interface, in which case the event type is
+ * DNS_EVENT_IMPORTRECVDONE, receive operation must be pending.
+ */
INSIST(disp->recv_pending != 0);
disp->recv_pending = 0;
}
/*
* General flow:
*
- * If I/O result == CANCELED, EOF, or error, free the buffer
- * and notify everyone as the various queues drain.
+ * If I/O result == CANCELED, EOF, or error, notify everyone as the
+ * various queues drain.
*
- * If query:
- * if no listeners: free the buffer, restart.
- * if listener: allocate event, fill in details.
- * If cannot allocate, free buffer, restart.
- * if rq event queue is not empty, queue. else, send.
- * restart.
+ * If query, restart.
*
* If response:
* Allocate event, fill in details.
- * If cannot allocate, free buffer, restart.
- * find target. If not found, free buffer, restart.
+ * If cannot allocate, restart.
+ * find target. If not found, restart.
* if event queue is not empty, queue. else, send.
* restart.
*/
* free the event *before* calling destroy_disp().
*/
isc_event_free(&ev_in);
-
+
disp->shutting_down = 1;
disp->shutdown_why = tcpmsg->result;
{
disp->attributes |= DNS_DISPATCHATTR_NOLISTEN;
if (disp->recv_pending != 0)
- isc_socket_cancel(disp->socket, NULL,
+ isc_socket_cancel(disp->socket, disp->task,
ISC_SOCKCANCEL_RECV);
}
killit = ISC_FALSE;
if (disp->refcount == 0) {
if (disp->recv_pending > 0)
- isc_socket_cancel(disp->socket, NULL,
+ isc_socket_cancel(disp->socket, disp->task,
ISC_SOCKCANCEL_RECV);
disp->shutting_down = 1;
}
killit = ISC_FALSE;
if (disp->refcount == 0) {
if (disp->recv_pending > 0)
- isc_socket_cancel(disp->socket, NULL,
+ isc_socket_cancel(disp->socket, disp->task,
ISC_SOCKCANCEL_RECV);
disp->shutting_down = 1;
}
LOCK(&disp->lock);
- if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) != 0 &&
- (attributes & DNS_DISPATCHATTR_NOLISTEN) == 0)
- {
- disp->attributes &= ~DNS_DISPATCHATTR_NOLISTEN;
- startrecv(disp);
+ if ((mask & DNS_DISPATCHATTR_NOLISTEN) != 0) {
+ if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) != 0 &&
+ (attributes & DNS_DISPATCHATTR_NOLISTEN) == 0) {
+ disp->attributes &= ~DNS_DISPATCHATTR_NOLISTEN;
+ startrecv(disp);
+ } else if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN)
+ == 0 &&
+ (attributes & DNS_DISPATCHATTR_NOLISTEN) != 0) {
+ disp->attributes |= DNS_DISPATCHATTR_NOLISTEN;
+ if (disp->recv_pending != 0)
+ isc_socket_cancel(disp->socket, disp->task,
+ ISC_SOCKCANCEL_RECV);
+ }
}
disp->attributes &= ~mask;
INSIST(sevent->n <= disp->mgr->buffersize);
newsevent = (isc_socketevent_t *)
isc_event_allocate(disp->mgr->mctx, NULL,
- ISC_SOCKEVENT_RECVDONE, udp_recv,
+ DNS_EVENT_IMPORTRECVDONE, udp_recv,
disp, sizeof(isc_socketevent_t));
if (newsevent == NULL)
return;