timeout issue with UDNS

Abhijit Pandey abhijpandey at gmail.com
Fri Oct 23 00:59:44 MSD 2009


Hi Michael,
Sounds good. I will try inserting from the head.

I think you got my problem. While processing the queries

We are only looking at the head
q = qlist_first(&ctx->dnsc_qactive);

So if new queries are being inserted continually at the head.
we will continually break out from the loop and not process the
already expired queries.

do {
    if (q->dnsq_deadline > now) { /* first non-expired query */
      int w = (int)(q->dnsq_deadline - now);
      if (maxwait < 0 || maxwait > w)
        maxwait = w;
      break;
    }

I am passing a -o timeout:3 to option to the library, but don't see
them timing out in 3 seconds at a high submission rate(100/sec)

Abhijit


On Thu, Oct 22, 2009 at 1:00 PM, Michael Tokarev <mjt at tls.msk.ru> wrote:
> 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