[nginx] Upstream: avoid holding a cache node with upgraded connections.

Maxim Dounin mdounin at mdounin.ru
Thu Nov 3 14:10:23 UTC 2016


details:   http://hg.nginx.org/nginx/rev/93b294c5d581
branches:  
changeset: 6794:93b294c5d581
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Nov 03 17:09:32 2016 +0300
description:
Upstream: avoid holding a cache node with upgraded connections.

Holding a cache node lock doesn't make sense as we can't use caching
anyway, and results in "ignore long locked inactive cache entry" alerts
if a node is locked for a long time.

The same is done for unbuffered connections, as they can be alive for
a long time as well.

diffstat:

 src/http/ngx_http_upstream.c |  17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diffs (34 lines):

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
@@ -2760,6 +2760,15 @@ ngx_http_upstream_send_response(ngx_http
     u->header_sent = 1;
 
     if (u->upgrade) {
+
+#if (NGX_HTTP_CACHE)
+
+        if (r->cache) {
+            ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
+        }
+
+#endif
+
         ngx_http_upstream_upgrade(r, u);
         return;
     }
@@ -2790,6 +2799,14 @@ ngx_http_upstream_send_response(ngx_http
 
     if (!u->buffering) {
 
+#if (NGX_HTTP_CACHE)
+
+        if (r->cache) {
+            ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
+        }
+
+#endif
+
         if (u->input_filter == NULL) {
             u->input_filter_init = ngx_http_upstream_non_buffered_filter_init;
             u->input_filter = ngx_http_upstream_non_buffered_filter;



More information about the nginx-devel mailing list