[PATCH] Upstream: avoid closing client conn when no response body needed

Justin Li jli.justinli at gmail.com
Wed Mar 9 03:25:54 UTC 2016

Thanks for your quick response again.

On Tue, Mar 8, 2016 at 10:04 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> If p->downstream_error is set from the very start there is no
> harm, as there are no busy buffers.  And the same is true if
> there is a real error and we don't need to send anything - these
> buffers won't be used, so they can be drained (other code have to
> be careful to don't trigger false alerts though).
> The problem with your previous patch is that you've tried to drain
> buffers in the p->downstream_done case, when p->busy buffers are
> important and can contain real data (already passed to output
> filters though not yet sent to the client).

In the original patch, downstream_done was being set at the same point
downstream_error was previously set, inside the first header_only check of
ngx_http_upstream_send_response. Is the reason for your original comment
about busy buffer corruption because this flag is set in another place as
well? If not, then I still don't understand why the original patch would
cause issues. If so, then it seems like the cleanest solution is to
introduce another flag (perhaps downstream_drain) that can be used in this

Justin Li
Developer @ Shopify
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160308/5166aee5/attachment.html>

More information about the nginx-devel mailing list