Timers in libwww 5.1b

 Dear libwww experts,
 
 I seem to have problems to understand the Timer Class
 of libwww 5.1b properly. The documentation in
    http://www.w3.org/pub/WWW/Library/src/HTTimer.html
 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);
       else
	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)
	HT_FREE(timer);
	
 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) {
	HTDebugBreak();
	CLEARME(timer);
	return HT_ERROR;
         }
        HTList_quickRemoveElement(cur, last);
        ret = (*timer->cbf) (timer, timer->param, HTEvent_TIMEOUT);
        HT_FREE(timer);
        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
Gustaf.Neumann@uni-essen.de
http://nestroy.wi-inf.uni-essen.de/Neumann.html

Received on Monday, 5 May 1997 17:31:56 UTC