upstream keepalive - call for testing

Matthieu Tourne matthieu.tourne at gmail.com
Thu Sep 8 22:05:01 UTC 2011


On Thu, Sep 8, 2011 at 2:27 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Wed, Sep 07, 2011 at 04:33:38PM -0700, Matthieu Tourne wrote:
>
> > Thanks for the all-included patch from 1.1.2
> >
> > It seems that keepalive connections aren't working in combination with
> > proxy_buffering off; (c->read->ready is set to 1)
> > It worked before this last update, is this the intended behavior ?
>
> Linux with epoll, right?  Please try the following patch:
>

Yes, Linux with epoll.
The patch below seems to fix the issue. Thank you Maxim!


>
> diff --git a/src/http/modules/ngx_http_upstream_keepalive_module.c
> b/src/http/modules/ngx_http_upstream_keepalive_module.c
> --- a/src/http/modules/ngx_http_upstream_keepalive_module.c
> +++ b/src/http/modules/ngx_http_upstream_keepalive_module.c
> @@ -321,7 +321,6 @@ ngx_http_upstream_free_keepalive_peer(ng
>     if (kp->failed
>         || c == NULL
>         || c->read->eof
> -        || c->read->ready
>         || c->read->error
>         || c->read->timedout
>         || c->write->error
> @@ -382,6 +381,10 @@ ngx_http_upstream_free_keepalive_peer(ng
>     item->socklen = pc->socklen;
>     ngx_memcpy(&item->sockaddr, pc->sockaddr, pc->socklen);
>
> +    if (c->read->ready) {
> +        ngx_http_upstream_keepalive_close_handler(c->read);
> +    }
> +
>  invalid:
>
>     kp->original_free_peer(pc, kp->data, state);
> diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
> --- a/src/http/ngx_http_upstream.c
> +++ b/src/http/ngx_http_upstream.c
> @@ -2142,7 +2142,7 @@ ngx_http_upstream_send_response(ngx_http
>                 return;
>             }
>
> -            if (u->peer.connection->read->ready) {
> +            if (u->peer.connection->read->ready || u->length == 0) {
>                 ngx_http_upstream_process_non_buffered_upstream(r, u);
>             }
>         }
>
> Second part fixes one more problem with handling of responses with
> empty body over keepalive connections, found during testing with
> various event methods.
>
> Maxim Dounin
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20110908/42843394/attachment.html>


More information about the nginx mailing list