[PATCH] Upstream: avoid closing client conn when no response body needed
mdounin at mdounin.ru
Wed Mar 9 15:22:43 UTC 2016
On Tue, Mar 08, 2016 at 10:25:54PM -0500, Justin Li wrote:
> 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
> 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
I don't see reasons why we need another flag (or the flag at all)
to handle this case. Just finalizing the request as in your last
patch will handle things correctly.
More information about the nginx-devel