W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1997

Timers in libwww 5.1b

From: Gustaf Neumann <neumann@nestroy.wi-inf.uni-essen.de>
Date: Mon May 5 17:31:56 1997
Message-Id: <9705052131.AA21632@nestroy.wi-inf.uni-essen.de>
To: www-lib@w3.org

 Dear libwww experts,
 I seem to have problems to understand the Timer Class
 of libwww 5.1b properly. The documentation in
 states that
     The Timer class handles timer for libwww and the application. 
     This works exactly as in X where you create a timer object with 
     a callback function and a timeout. The callback will be called 
     every time the timer expires. 

 A timer can be relative or not (absolute). From the source I can 
 see that a relative timer has also another property, it is repetitious:
 if the timer is dispatched, it resurrects magically before it executes
 the registered callback function:

     PRIVATE int Timer_dispatch (HTList * cur, HTList * last, int now)
        if (timer->relative)
	HTTimer_new(timer, timer->cbf, timer->param, timer->millis, YES);
	HTList_quickRemoveElement(cur, last);
       if (THD_TRACE) HTTrace("Timer....... Dispatch timer %p\n", timer);
   /*    CHECKME(timer); all entries to this function are now re-entry save */
       ret = (*timer->cbf) (timer, timer->param, HTEvent_TIMEOUT);
   /*    CLEARME(timer); */
       if (!timer->relative)
 Why is this? The cited documentation suggests similarities to 
 the XtAppAddTimeout function, which is relative and non-repetitious.....
 The reason I went into this is because I register Xt Timeouts
 via HTTimer_registerSetTimerCallback(). These callbacks are
 called sometimes with invalid data (callbacks registered with relative
 timeouts from  HTBufferWriter_lazyFlush () in  HtBufWrt.c). I can solve
 this problem by modifying Timer_dispatch() to 
      PRIVATE int Timer_dispatch (HTList * cur, HTList * last, int now)
          HTTimer * timer;
          int ret;

          timer = (HTTimer *)HTList_objectOf(cur);
          if (timer == NULL) {
	return HT_ERROR;
        HTList_quickRemoveElement(cur, last);
        ret = (*timer->cbf) (timer, timer->param, HTEvent_TIMEOUT);
        return ret;

 This modification removes the -undocumented- repetitious property.
 Now everything works as expected on my side. 
 Is the repetitious behavior intended? If yes, it should be documented
 and I have to study on, why I get sometimes invalid data (it seems as 
 if the timer structure is freed somewhere before it is passed to the 
 callback function).
 If the repetitious behavior is not intended I would suggest the 
 change above.
 Best regards

 -gustaf neumann
Wirtschaftsinformatik und Softwaretechnik        
Universitaet GH Essen, FB5
Altendorfer Strasse 97-101, Eingang B, D-45143 Essen
Tel.: +49 (0201) 81003-74, Fax:  +49 (0201) 81003-73
Received on Monday, 5 May 1997 17:31:56 UTC

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