httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Querna <>
Subject Re: Anyone here with knowledge of MPM event?
Date Mon, 15 Sep 2008 08:37:18 GMT
Rustam Abdullaev wrote:
> Hi all,
> I need some help with the (experimental) event MPM. I want to extend it to 
> support suspendable requests (for comet). Any help is appreciated!

Hi Rustam,

Funny that you mention suspendable requests, I've been thinking about it 
for other reasons recently :-)

The event mpm is likely the right place to start since it already have a 
concept of suspendable 'conections', but how it is done is specific to 
HTTP., However, the problems with making a suspendable *request* are 
much deeper in the other parts of the core, and less of a problem in the 

The first major problem is the filter stack and how handlers are invoked.

A content handler, writes to the filter stack directly, each filter 
invokes the next in the chain, from within its own function.

A filter can choose to buffer, or do whatever it likes with the content.

When a handler is done, it inserts an EOS bucket, which is supposed to 
tell all filters to flush, since it is the end of the current request.

I think the first step, which while complicated, might be the easiest 
way to demo this, is to make a custom static file handler, which would 
write the file at a constant bitrate, ie, 500 kbs.

To do this you would write a file bucket of X length, insert a 'fake' 
EOS, and write it like normal.  You would also have a custom filter that 
would remove the early EOS before it hit the core network filter.  Once 
the first 'pulse' happens, you would then suspend the request for Z 
milliseconds, and modify the event mpm to re-invoke the handler at the 
desired time.

I think the easiest way would be to add a return value from the handler, 
  SUSPEND, which the core would then not do anything extra with, 
assuming that the MPM will call the handler again at the desired time. 
Inside the handler, you would have for example, something like this:

  ap_mpm_query(AP_MPM_SUSPEND_REQUESTS, &sr);

  if (sr) {
    ap_mpm_suspend_request(r, your_function_callback, void_baton, 200ms);
    return SUSPEND;
  else {
    return run_request_as_normal();

Thats my basic thoughts, assuming you don't want to rewrite the entire 
filter chain, which is something I've been trying to avoid :-)



View raw message