Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-03-23 00:31:06 UTC
Modified files:
ChangeLog ircd/ircd_events.c ircd/ircd_res.c
Log message:
Fix DNS-related timer assertion failure.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.572 ircu2.10/ChangeLog:1.573
--- ircu2.10/ChangeLog:1.572 Tue Mar 22 16:25:16 2005
+++ ircu2.10/ChangeLog Tue Mar 22 16:30:55 2005
@@ -1,5 +1,17 @@
2005-03-22 Michael Poole <[EMAIL PROTECTED]>
+ * ircd/ircd_events.c (timer_chg): Properly change a timer that is
+ in the middle of executing its expiration event.
+
+ * ircd/ircd_res.c (check_resolver_timeout): Simplify the test for
+ whether to use timer_chg() or timer_add().
+ (timeout_resolver): Do not try to re-schedule the DNS timeout
+ unless it is the expiration event.
+ (do_query_number): Properly initialize request->state.
+ (res_readreply): Mention the response code that was bad.
+
+2005-03-22 Michael Poole <[EMAIL PROTECTED]>
+
* ircd/engine_kqueue.c (engine_delete): The kernel removes
close()'d FDs from the activity list, so don't try to remove the
FD here (the caller may have already close()'d it).
Index: ircu2.10/ircd/ircd_events.c
diff -u ircu2.10/ircd/ircd_events.c:1.9 ircu2.10/ircd/ircd_events.c:1.10
--- ircu2.10/ircd/ircd_events.c:1.9 Fri Dec 10 21:13:44 2004
+++ ircu2.10/ircd/ircd_events.c Tue Mar 22 16:30:56 2005
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Implementation of event loop mid-layer.
- * @version $Id: ircd_events.c,v 1.9 2004/12/11 05:13:44 klmitch Exp $
+ * @version $Id: ircd_events.c,v 1.10 2005/03/23 00:30:56 entrope Exp $
*/
#include "config.h"
@@ -525,12 +525,19 @@
"timeout %Tu", timer, timer_to_name(timer->t_type), timer->t_value,
timer_to_name(type), value));
- gen_dequeue(timer); /* remove the timer from the queue */
-
timer->t_type = type; /* Set the new type and value */
timer->t_value = value;
timer->t_expire = 0;
+ /* If the timer expiration callback tries to change the timer
+ * expiration, flag the timer but do not dequeue it yet.
+ */
+ if (timer->t_header.gh_flags & GEN_MARKED)
+ {
+ timer->t_header.gh_flags |= GEN_READD;
+ return;
+ }
+ gen_dequeue(timer); /* remove the timer from the queue */
timer_enqueue(timer); /* re-queue the timer */
}
Index: ircu2.10/ircd/ircd_res.c
diff -u ircu2.10/ircd/ircd_res.c:1.17 ircu2.10/ircd/ircd_res.c:1.18
--- ircu2.10/ircd/ircd_res.c:1.17 Sun Mar 20 08:06:18 2005
+++ ircu2.10/ircd/ircd_res.c Tue Mar 22 16:30:56 2005
@@ -18,7 +18,7 @@
*/
/** @file
* @brief IRC resolver functions.
- * @version $Id: ircd_res.c,v 1.17 2005/03/20 16:06:18 entrope Exp $
+ * @version $Id: ircd_res.c,v 1.18 2005/03/23 00:30:56 entrope Exp $
*/
#include "client.h"
@@ -278,23 +278,26 @@
{
if (when > CurrentTime + AR_TTL)
when = CurrentTime + AR_TTL;
- if (!t_active(&res_timeout) || !t_onqueue(&res_timeout))
- timer_add(&res_timeout, timeout_resolver, NULL, TT_ABSOLUTE, when);
- else if (when < t_expire(&res_timeout))
+ if (t_onqueue(&res_timeout))
timer_chg(&res_timeout, TT_ABSOLUTE, when);
+ else
+ timer_add(&res_timeout, timeout_resolver, NULL, TT_ABSOLUTE, when);
}
/** Drop pending DNS lookups which have timed out.
* @param[in] notused Timer event data (ignored).
*/
static void
-timeout_resolver(struct Event *notused)
+timeout_resolver(struct Event *ev)
{
struct dlink *ptr, *next_ptr;
struct reslist *request;
time_t next_time = 0;
time_t timeout = 0;
+ if (ev_type(ev) != ET_EXPIRE)
+ return;
+
for (ptr = request_list.next; ptr != &request_list; ptr = next_ptr)
{
next_ptr = ptr->next;
@@ -509,6 +512,7 @@
if (request == NULL)
{
request = make_request(query);
+ request->state= REQ_PTR;
request->type = T_PTR;
memcpy(&request->addr, addr, sizeof(request->addr));
request->name = (char *)MyMalloc(HOSTLEN + 1);
@@ -800,7 +804,7 @@
* If a bad error was returned, we stop here and don't send
* send any more (no retries granted).
*/
- Debug((DEBUG_DNS, "Request %p has bad response (state %d type %d)",
request, request->state, request->type));
+ Debug((DEBUG_DNS, "Request %p has bad response (state %d type %d rcode
%d)", request, request->state, request->type, header->rcode));
(*request->query.callback)(request->query.vptr, 0);
rem_request(request);
}
----------------------- End of diff -----------------------