W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2000

Bug in HTTimer.c

From: Jens Meggers <jens@meggers.com>
Date: Thu, 13 Jul 2000 17:36:48 +0200
Message-ID: <00fd01bfece0$28ab5610$6b02a8c0@pille>
To: <www-lib@w3.org>

I'm very sure that I found a bug in HTTimer.c. It does only concern Win32 applications in Async mode:

When a timer event happens, it is dispatched by the event loop and the hidden window procedure from the event loop procedure. In Timer_dispatch(..), the event is removed from the event list in case it is not a repetitive event. The procedure calls HTList_quickRemoveElement() to get rid of the event. However, on Win32, events triggered by SetTimer() are always repetitive, so that one has to call KillTimer() to get rid of the corresponding WM_TIMER messages. Thus, the code has to be changed to:

>    if (timer->repetitive)
> HTTimer_new(timer, timer->cbf, timer->param, timer->millis, YES, YES);
>    else
> HTList_quickRemoveElement(cur, last);
 // on windows we have to stop the timer 
>    HTTRACE(THD_TRACE, "Timer....... Dispatch timer %p\n" _ timer);
>    ret = (*timer->cbf) (timer, timer->param, HTEvent_TIMEOUT);
>    return ret;

The bug is not really dangerous to you applications. Whithout the patch, your application gets slower after each HTTP request. When a single request is finished, the timer remains in the system and occurs 100 times per second. When dispatched, no procedure is called because the attached timer pointer is NULL. This code is located in Timer_dispatch():

if (timer == NULL) {
#if 0
        HTDEBUGBREAK("Timer dispatch couldn't find a timer\n");
 return HT_ERROR;

Thus, Timer_dispatch() always returns HT_ERROR for each timer that has not been killed. When writing a robot or a server, this can become a huge portion of CPU resources.

Please give some feedback when you think I'm wrong.

Best regards,

Received on Thursday, 13 July 2000 11:33:57 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:53 UTC