RE: HTEventList_loop on Windows

> Is this modification correct?

For me this is not correct.

My program does multiples requests.
(see the mget.c sample)
I don't want to exit the event loop
just because one of them is unreacheable.

> Or, do you have a nice idea for this problem?

I don't know if it is nice but here is how I do
"by request" timeouts:

  ...
  HTRequest request = HTRequest_new();
  HTRequest_setContext(request,  myReq);  
  myReq->timer = HTTimer_new(NULL, timer_callback, (void*)myReq, tm, true,
false);  
   ...

int timer_callback(HTTimer* timer, void * param, HTEventType type) 
{
    t_myReq *myReq = (t_myReq *)inst;
    HTRequest request = myReq->request;
    HTTimer_delete(timer);
    myReq->timer = NULL;

    // To kill the request use:
    /* 
    HTNet *net = HTRequest_net(request);
    HTNet_killPipe(net);
    */
}

 

-----Original Message-----
From: Shigeyuki Fukushima [mailto:shige@sitc.toshiba.co.jp] 
Sent: vendredi 15 février 2002 02:32
To: www-lib@w3.org
Cc: shige@sitc.toshiba.co.jp
Subject: HTEventList_loop on Windows


Hello.

Now I'm using w3c-libwww-5.3.2 on x86/Windows platform.
I have found a fatal bug(?) in HTEventList_loop function.

When compiling Library/src/HTEvtLst.c with WWW_WIN_ASYNC definition.
`HTHost_setEventTimeout(60000);' operation has no effect for
main event loop.
When a program sent a http request for an unreachable URL, 
it cannot escape main event loop parmanently, even if
HTHost_setEventTimeout() is called before in loop.

Then, I tried to modify HTEvtLst.c as follows (add):

PUBLIC int HTEventList_loop (HTRequest * theRequest)
{
#ifdef WWW_WIN_ASYNC

    MSG msg;
    int status;
    ms_t timeout;
    while (!HTEndLoop && GetMessage(&msg,0,0,0)) {
            /* add FROM */
            if ((status = HTTimer_next(&timeout)))
                break;
            /* add TO */
            TranslateMessage(&msg);
            DispatchMessage(&msg);
    }

    status = HTEndLoop;
    
    /* Reset HTEndLoop in case we want to start again */
    HTEndLoop = 0;
    
    return (status == 1 ? HT_OK : HT_ERROR);

#else /* WWW_WIN_ASYNC */
     :
}

Is this modification correct?
Or, do you have a nice idea for this problem?

Thanks.

--- shige
Shigeyuki Fukushima 
   shige@sitc.toshiba.co.jp
   shige@FreeBSD.org

Received on Thursday, 21 February 2002 03:10:08 UTC