Hi all, Continuing on from the discussion about how we might support write completion in mod_ssl, I have come up with the following patch below.
I started by changing the event MPM to call all protocol filters instead of just the hard coded write filter: rv = ap_pass_brigade(c->output_filters, cs->bb); The first thing that this revealed was that we need to pass a non-empty brigade down the stack. I needed a metadata bucket to pass down the stack to make the brigade not-empty, and so chose to create a metadata bucket for this purpose (more on this below). The second thing that we needed to support for mod_ssl to have any hope of taking advantage of write completion was non-blocking writes to the core output filter. This would give mod_ssl the option to setaside any large buckets (example: file buckets) and allow the core to enter write completion as soon as it saw EAGAIN. We can't change the API for ap_pass_brigade() to add a nonblock flag like an input filter, but we can pass a NONBLOCK metadata bucket down the stack, and this dovetails nicely with our need for a metadata bucket above. So, this patch does the following: - Takes out the "pass NULL to the core output filter" hack that supported write completion previously in the event MPM (other MPMs to follow). - Add the nonblock bucket, and pass this bucket down the protocol stack during write completion. - Teach the core output filter how to react to the NONBLOCK bucket, returning APR_EAGAIN appropriately when the NONBLOCK bucket is present (and APR_SUCCESS when not, as per previous behaviour). In theory, this opens the door for us to support asynchronous filters that know about NONBLOCK buckets and nonblocking behaviour. In the case of naive filters, we may end up with existing blocking behaviour during write completion, but this is no worse than we have now. Also in theory, all of this can be backported to v2.4. Regards, Graham --
httpd-core-nonblocking.patch
Description: Binary data