[nginx] Upstream: u->length now defaults to -1 (API change).

Maxim Dounin mdounin at mdounin.ru
Thu Jul 25 11:58:56 UTC 2013


details:   http://hg.nginx.org/nginx/rev/f538a67c9f77
branches:  
changeset: 5300:f538a67c9f77
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Jul 25 14:58:11 2013 +0400
description:
Upstream: u->length now defaults to -1 (API change).

That is, by default we assume that response end is signalled by
a connection close.  This seems to be better default, and in line
with u->pipe->length behaviour.

Memcached module was modified accordingly.

diffstat:

 src/http/modules/ngx_http_memcached_module.c |  5 ++++-
 src/http/ngx_http_upstream.c                 |  2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff --git a/src/http/modules/ngx_http_memcached_module.c b/src/http/modules/ngx_http_memcached_module.c
--- a/src/http/modules/ngx_http_memcached_module.c
+++ b/src/http/modules/ngx_http_memcached_module.c
@@ -441,8 +441,11 @@ ngx_http_memcached_filter_init(void *dat
     u = ctx->request->upstream;
 
     if (u->headers_in.status_n != 404) {
-        u->length += NGX_HTTP_MEMCACHED_END;
+        u->length = u->headers_in.content_length_n + NGX_HTTP_MEMCACHED_END;
         ctx->rest = NGX_HTTP_MEMCACHED_END;
+
+    } else {
+        u->length = 0;
     }
 
     return NGX_OK;
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
@@ -1994,7 +1994,7 @@ ngx_http_upstream_process_headers(ngx_ht
 
     r->headers_out.content_length_n = u->headers_in.content_length_n;
 
-    u->length = u->headers_in.content_length_n;
+    u->length = -1;
 
     return NGX_OK;
 }



More information about the nginx-devel mailing list