On 24 Jun 2015, at 4:07 PM, Stefan Eissing <stefan.eiss...@greenbytes.de> wrote:
> Hmm, yes, well. It's the thought that counts... ;-) > > I think this will not be enough, though, if I understood the failures of my > various attempts correctly. But it will certainly be good if more heads than > one have a go at this. > > Let Tm :-= main thread, Tw := worker thread, TmB() the main connection bucket > brigade, TwB() the worker (request) brigade. > > When a response from a worker starts: > TmB( , , , , , , , ) TwB(b1,b2,b3, , , , ) > so we move buckets across threads > TmB(b1,b2, , , , , , ) TwB(b3, , , , , , ) > and send b1 out and new response data arrives > TmB(b2, , , , , , , ) TwB(b3,b4, , , , , ) > we have the destruction of b1 and the creation of b4 that go against the same > bucket_alloc_t instance from two threads. > > Similar operations happen when b1 needs to be split or is a file bucket that > gets read. So refraining from destroying buckets in the main thread is not > enough. > > Have I missed something here? In theory, a bucket should only be considered by one thread at a time. A brigade containing buckets may be worked on by a different thread, but this should never happen concurrently with another thread. Am I right in understanding that the problem comes about when there is a transition of a bucket from the “slave” connection to the “master” connection? In theory, if the “slave” connection was terminated by a filter that collected buckets and set them aside in a brigade, and the “master” connection started with a filter that collected buckets from various brigades and then sent them down the rest of the filter chain we would solve any threading issues. We would probably need some kind of mechanism for flow control, so that we could temporarily suspend a “slave” connection until the master is ready to receive more data from that connection, but this should be straightforward. I was working on a patch last year that allowed any filter to set aside buckets and return early before all data was processed. This may help you to implement the “slave to master” filters: http://mail-archives.apache.org/mod_mbox/httpd-dev/201409.mbox/%3c04776f50-0a53-4c1d-aa1c-9f57b60bc...@sharp.fm%3E Regards, Graham —