Usage of the shadow field in ngx_buf_t?

Brian Pane brianp at brianp.net
Fri Dec 11 02:09:10 MSK 2009


On Sat, Dec 5, 2009 at 4:06 PM, Brian Pane <brianp at brianp.net> wrote:
[...]
> Thanks.  What is the right thing to do if a body filter consumes
> only part of a buf and sets aside the rest for later?

I ended up using a reference-counting design for this.  I "subclassed"
ngx_buf_t by allocating a structure with an ngx_buf_t at the start
(so all the nginx core code thinks it's a normal ngx_buf_t) and extra
fields for a references and counts at the end.  It's a bit of a hack,
but it works well.

-Brian



More information about the nginx-devel mailing list