timeout issue with UDNS

Michael Tokarev mjt at tls.msk.ru
Fri Oct 23 00:00:06 MSD 2009


Abhijit Pandey пишет:
> Hi Michael,
> 
> There seems to be  a bug in submitting queries.
> The queries are added to the list of active queries at the head.
> 
> The last Query added to list is on top.
> 
> When timeout is called.
> We are only looking at the head of the active query, and ignoring the rest.
> Since the queries at tail end were added first, the timeouts on the
> tail end queries will happen only when the head end queries time out.
> 
> When we resend the query. It is attached correctly to the list.
> 
>    /* insert from the tail */
>     struct dns_query *p;
>     QLIST_FOR_EACH(&ctx->dnsc_qactive, p, prev)
>       if (p->dnsq_deadline <= q->dnsq_deadline)
>     break;
>     qlist_insert_after(q, p);
> 
> 
> Shouldn't we do the same while submitting the queries too.

No.  Because new queries always start with timeout of 1sec.
On the top of the list (head of it) we have entries which
has >=1 sec before expire time, and we're adding new entry
with expire time = 1sec.  It's the head of the list.

The only possible problem here is if there are already
expired entries in the head of the list.  But it should
not happen if the queue gets processed in time.

Well.  It probably is possible to have already expired
entries on the head of the list.  When we process the
queue (but didn't finish yet), we called some callback
routine and from that routine we receive another request.
Interesting.

>>>> qlist_add_head(q, &ctx->dnsc_qactive);
> 
> replaced by
>    /* insert from the tail */
>     struct dns_query *p;
>     QLIST_FOR_EACH(&ctx->dnsc_qactive, p, prev)
>       if (p->dnsq_deadline <= q->dnsq_deadline)
>     break;
>     qlist_insert_after(q, p);

With one difference: we should insert from the head,
not from the tail.  So,

 >     QLIST_FOR_EACH(&ctx->dnsc_qactive, p, next)
 >       if (p->dnsq_deadline >= q->dnsq_deadline)
 >         break;
 >     qlist_insert_before(q, p);

or something like that.

What problem are you trying to solve?

/mjt


More information about the udns mailing list