upstream keepalive variable

洪志道 hongzhidao at gmail.com
Sun Jun 12 12:22:25 UTC 2016


Hi,

It seems to we can't check a request whether used upstream keepalive, so I
add
the following code with an additional variable named $upstream_keepalive.

static ngx_int_t

ngx_http_upstream_keepalive_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v,

    uintptr_t data)

{

    if (r->upstream_states == NULL || r->upstream_states->nelts == 0 ||
r->upstream->peer.cached == 0) {

        v->data = (u_char *) "0";


    } else {

        v->data = (u_char *) "1";

    }


    v->len = 1;

    v->valid = 1;

    v->no_cacheable = 0;

    v->not_found = 0;


    return NGX_OK;

}


Help check it, thanks a lot!


B.R.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160612/00fe4538/attachment.html>


More information about the nginx-devel mailing list