1 Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
2 Copyright (C) 2000, 2001 Internet Software Consortium.
3 See COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
5 $Id: dispatch,v 1.6 2004/03/05 05:04:46 marka Exp $
12 * If I/O result == CANCELED, free the buffer and notify everyone as
13 * the various queues drain.
15 * If I/O is error (not canceled and not success) log it, free the buffer,
19 * if no listeners: free the buffer, restart.
20 * if listener: allocate event, fill in details.
21 * If cannot allocate, free buffer, restart.
22 * if rq event queue is not empty, queue. else, send.
26 * Allocate event, fill in details.
27 * If cannot allocate, free buffer, restart.
28 * find target. If not found, free buffer, restart.
29 * if event queue is not empty, queue. else, send.
37 * If too many recv()'s are already running, just return.
39 * If noone is attached to us, just return.
41 * Allocate a new buffer to receive into.
43 * If there are buffers handed out: wait for one to come back.
44 * If there are no buffers handed out:
45 * If there are responses attached to us, just return.
46 * If there are queries only, send one an error event.
49 * start recv() on socket. If this fails:
51 * Set dispatch state to "shutting down" and why to "socket error"
52 * Start failsafe shutdown.
59 * If shutting down, return error.
61 * Allocate an unique messageid and return it. If none can be allocated,
64 * Allocate a new structure and fill it in. If no memory, return that.
66 * Insert into the correct linked list.
68 * If the receiver is not running, try to start it.
74 * If shutting down, return error.
76 * Allocate new structure and fill it in. If no memory, return that.
78 * Insert it into the linked list.
80 * If the incoming query packet queue is not empty, pull an item off and
81 * send that event to this task.
83 * If the receiver is not running, try to start it.
89 * decrement dispatch reference count by one. If zero, remember to kill it
92 * unlink the response from the hashed list.
94 * Free any buffers and events attached to the response structure.
96 * Free the response structure.
98 * If an event is also being returned, jump to "internal event free" below.
100 * If the ref count became zero above, destroy this dispatch fully, and return.
102 * If the receiver is not running, try to start it.
108 * decrement dispatch ref count by one. If zero, remember to kill it later.
110 * unlink from the request list.
112 * Free the response structure.
114 * If an event is also being returned, jump to "internal event free" below.
116 * If the ref count became zero above, destroy the dispatch fully, and return.
118 * If the receiver is not running, try to start it.
121 Internal event free (from library space):
124 * If it is the failsafe event, send it to the next response/request on the
125 * dispatcher, and return.
132 Returning an event (from application space):
135 * If it is the failsafe event, die.
137 * Free associated buffer.
141 * If response: do next response on this response's queue, if any.
142 * If request: do next request on this dispatcher's queue, if any.
144 * If the receiver is not running, try to start it.