You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Greg Stein <gs...@lyra.org> on 2000/06/26 06:54:52 UTC

events and saved-state (was: Re: PLEASE READ: Filter I/O)

On Mon, Jun 26, 2000 at 01:46:17AM +0100, Tony Finch wrote:
> Greg Stein <gs...@lyra.org> wrote:
> >Tony Finch wrote:
> >
> >In the hook scheme, there are two options to the large database content
> >issue:
> >
> >1) suck the whole thing into memory and return an ioblock pointing to it
> >2) suck in a portion, return it in an ioblock, and return "call me again
> >   because I have more to give you."
> >
> >I have labeled (2) as an "asynchronous style of programming."
> 
> I prefer to call it event-driven. "Async" seems to have too many
> different meanings. This style is the main point of the hooked filters.

Fair enough.

As you pointed out further in this note (and rightfully so), any filtering
scheme is going to have some amount of event-driven code in it. If you're
implementing SSI as a filter, and you don't have a complete directive, then
you must save away some state and wait for the rest of the directive.

My issue with option (2) above, is that it adds *another* set of events into
your code. Not only are you trying to deal with saving state for partial
inputs, but you're also doing it for partial outputs!

Event-driven programming is not fun at all. Having to deal with a couple
sets of events and state that are intertwined seems quite hopeless. :-)


Yes, mod_gargle sets aside some data for later use. Ryan's version would do
the same (his original example didn't, but theoretically should). Neither
scheme provides any particular advantages or detriments towards the "save
aside some input." Both schemes must copy and save the unhandled input,
since they cannot rely on it existing past the execution of, say,
ap_rwrite() [which in turns passes the content to the filters]. Ryan's code
is providing a bit of logic to support the "set aside" notion, but it
doesn't help with the other save-state that is necessary for this kind of
problem. My patch has a generic state pointer, but does not provide any
specific assistance.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/