W3C home > Mailing lists > Public > www-lib@w3.org > October to December 1998

Re: How to stop the event loop?

From: Henrik Frystyk Nielsen <frystyk@w3.org>
Date: Mon, 14 Dec 1998 17:07:33 -0500
Message-Id: <>
To: Jim_Ravan@avid.com, www-lib@w3.org
At 14:06 12/14/98 -0500, Jim_Ravan@avid.com wrote:
>I'm trying to write a "standard" AFTER filter that I will use in lots of
>places to stop the event loop. Currently my Put code looks something like:
>     // Perform a ranged PUT on that anchor.
>     request = HTRequest_new();
>     HTRequest_addRange(request, "bytes", rangeStr);
>     HTRequest_addAfter(request, endRequest, NULL, NULL, HT_ALL,
>     if (HTPutAbsolute(HTAnchor_parent(anchor), urlStr, request)) {
>          HTEventList_loop(request);
>          err = OK;
>     } else {
>          err = NO;
>     }
>     static int endRequest(HTRequest* req, HTResponse* res, void* param,
>int status) {
>          HTEventList_stopLoop();
>          return HT_OK;
>     }
>My first question is "Is this an acceptable way to stop the event loop?".
>If so, it seems that endRequest() does not handle redirections, and if one
>is in progress, this filter will stop the redirection.

If you are using the default, global AFTER filters which you get when
creating a profile calling HTAfterInit() in


and you don't override the global filters with local filters for any
particular request (which you haven't done here) then the default
redirection filter will handle this and issue a new request and break the
filter line so that your filter isn't called. The same is the case for
authentication, for example.

That is, the sample program


in fact handles authentication and redirection and it has the same style of
"last filter" as you have.

Btw, you can register your after filter as a global filter which may be
easier if you are using it for all requests.

> Is this correct, and
>if so, how should the AFTER filter be coded so as to stop the event loop
>when the PUT has finished and, at the same time, handle redirections, etc?

Starting and stopping the eventloop doesn't impact which filters are
called. The thing you have to be careful about when stopping the event loop
is that all requests have terminated so that there are no ongoing requests
that suddenly are stopped because the eventloop has stopped.

You can find some more information on this at


Henrik Frystyk Nielsen,
World Wide Web Consortium
Received on Monday, 14 December 1998 17:07:38 UTC

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