Thanks From: nginx <nginx-boun...@nginx.org> on behalf of Maxim Dounin <mdou...@mdounin.ru> Date: Wednesday, 21 June 2023 at 19:01 To: Yuval Abadi via nginx <nginx@nginx.org> Subject: Re: nginx_http_write_filter_module.c EXTERNAL MAIL: nginx-boun...@nginx.org
Hello! On Wed, Jun 21, 2023 at 11:36:54AM +0000, Yuval Abadi via nginx wrote: > Nginx 1.23.2 > > The cpi ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) > > Loop over the request out buffers and in chain > > If calculate size of combined buffer to write. > > I add body replacement on chain. > It have value, but ngx_buf_size(cl->buf); > Return it have 0. Size. > > (l->buf->last - cl->buf->pos) give the correct size > > So the buffer not written. > > Only the header part send back to client > > Any idea? > > 2023/06/21 10:45:31 [debug] 22962#22962: *3 write old buf t:1 f:0 > 00005600970D81E0, pos 00005600970D81E0, size: 179 file: 0, size: 0 > 2023/06/21 10:45:31 [debug] 22962#22962: *3 write new buf t:0 f:0 > 00005600970D8098, pos 00005600970D8098, size: 247 file: 0, size: 0 > 2023/06/21 10:45:31 [debug] 22962#22962: *3 http write filter: l:1 f:0 s:179 > 2023/06/21 10:45:31 [debug] 22962#22962: *3 http write filter limit 2097152 > 2023/06/21 10:45:31 [debug] 22962#22962: *3 writev: 179 of 179 Note the "t:0" part in the relevant debug log line: it suggests that the cl->buf->temporary flag is not set. If the cl->buf->memory flag isn't set as well, this basically means that buffer does not reference any memory at all (even if cl->buf->post / cl->buf->last pointers are set). For such a buffer ngx_buf_size() will return the file size. And, since the buffer does not reference file data as well (note "f:0"), it is expected to be 0 (and it is, as per "file: 0, size: 0"). So it looks like the behaviour you observe is the result of forgotten cl->buf->memory (or cl->buf->temporary) flag. Check your code to see if the buffer flags are set correctly, it looks like they aren't. See https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fnginx.org%2Fen%2Fdocs%2Fdev%2Fdevelopment_guide.html%23buffer&data=05%7C01%7Cy.abadi%40f5.com%7C93490412a0ae47a77b2808db7270cf46%7Cdd3dfd2f6a3b40d19be0bf8327d81c50%7C0%7C0%7C638229601077880722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=lfQi%2FWoc7nk3Zr8R6I1X9DAE%2BZ36sfkMT6%2Fnw7YFgR8%3D&reserved=0<http://nginx.org/en/docs/dev/development_guide.html#buffer> for basic information about memory buffers and some basic examples. For additional information, check nginx code. -- Maxim Dounin https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmdounin.ru%2F&data=05%7C01%7Cy.abadi%40f5.com%7C93490412a0ae47a77b2808db7270cf46%7Cdd3dfd2f6a3b40d19be0bf8327d81c50%7C0%7C0%7C638229601077880722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rrIFE5kKXycRGSmQ64bP%2BwDfaqpEVKZfndVRYmgxNyE%3D&reserved=0<http://mdounin.ru/> _______________________________________________ nginx mailing list nginx@nginx.org https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.nginx.org%2Fmailman%2Flistinfo%2Fnginx&data=05%7C01%7Cy.abadi%40f5.com%7C93490412a0ae47a77b2808db7270cf46%7Cdd3dfd2f6a3b40d19be0bf8327d81c50%7C0%7C0%7C638229601077880722%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=R77KnZSvlfE6Uy7%2BHMZ5FwuvhKWrNJboV3tkV%2Frm2wc%3D&reserved=0<https://mailman.nginx.org/mailman/listinfo/nginx>
_______________________________________________ nginx mailing list nginx@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx