On 04/28/2016 02:40 AM, Yann Ylavic wrote: > On Wed, Apr 27, 2016 at 7:28 AM, Stefan Eissing > <stefan.eiss...@greenbytes.de> wrote: >> >> >>> Am 26.04.2016 um 23:57 schrieb Yann Ylavic <ylavic....@gmail.com>: >>> >>> On Tue, Apr 26, 2016 at 4:49 PM, Stefan Eissing >>> <stefan.eiss...@greenbytes.de> wrote: >>>> Today I Learned the difference between writing >>>> DATA + META >>>> and >>>> DATA + META + FLUSH >>>> to the core output filters. I am astonished that >>>> my code ever worked. >>>> >>>> Seriously, what is the reason for this kind of >>>> implementation? >>> >>> Do you mean why META could be destroyed before (setaside-)DATA, in >>> remove_empty_buckets()? >> >> Yes. That was unexpected. My understanding of the pass_brigade contract was >> that buckets get destroyed in order of appearance (might be after the call). > > Actually after re-reading the code, the core output filter looks good to me. > remove_empty_buckets() will only remove buckets up to DATA buckets, > and indeed httpd couldn't work otherwise. >
I agree with Yann here. I think there is no out of order destruction. Keep in mind that remove_empty_buckets does not clean the whole brigade of metadata and empty data buckets, but only all the ones that precede a non zero length data bucket. This seems correct. So as I read it actually the following happens: 1. The core output filter tries to sent as much data as it can non blocking. 2. We possibly have buckets left in the brigade after this. 3. We process all META databuckets and empty databuckets until we reach a non empty data bucket. 4. We set aside the remainder of the brigade for further processing in the future. So 3. doesn't do anything out of order. We can do this processing here since we do not need a writable socket for this at this point of time. But looking further at the code we indeed have some sort of out of order processsing, in the sense that we read data from data buckets, where we have metabuckets before them in the brigade that have not been processed (send_brigade_nonblocking). But once we start really sending the data we delete the appropriate buckets in the correct order (writev_nonblocking). Regards RĂ¼diger