]> git.kaiwu.me - nginx.git/commitdiff
Upstream: avoid holding a cache node with upgraded connections.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 3 Nov 2016 14:09:32 +0000 (17:09 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 3 Nov 2016 14:09:32 +0000 (17:09 +0300)
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.

src/http/ngx_http_upstream.c

index 1a657e6b3c8b744bf29aebb07d90db4956ed7677..fbd94d1395ee07b03849bfe0340d23d17d0b15ec 100644 (file)
@@ -2760,6 +2760,15 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
     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_request_t *r, ngx_http_upstream_t *u)
 
     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;