Upstream: fix proxy_store/fastcgi_store leaving temporary files.

Maxim Dounin mdounin at mdounin.ru
Mon Apr 27 01:35:14 MSD 2009


Hello!

Патч.

Исправляет проблему, из-за которой при использовании 
proxy_store/fastcgi_store могли оставаться временные файлы в 
proxy_temp_path/fastcgi_temp_path если клиент закрывал соединение 
преждевременно.

Спасибо Михаилу Монашёву за неиссякаемый источник клиентов, 
закрывающих соединение в самые неожиданные моменты :), а равно за 
спонсирование и тестирования патча в боевых условиях.

Maxim Dounin
-------------- next part --------------
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1240703167 -14400
# Node ID 656c35dee09831c907cbb2adc0df0e62f94f47be
# Parent  ea3064895a9d073363bb1f4b1a357bd603f5998e
Upstream: fix proxy_store/fastcgi_store leaving temporary files.

Temporary file in proxy_temp_path/fastcgi_temp_path were not always
removed or moved to new location if proxy_store/fastcgi_store directives
were used and client closed prematurely connection.

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
@@ -779,8 +779,12 @@ ngx_http_upstream_check_broken_connectio
     u = r->upstream;
 
     if (c->error) {
-        ngx_http_upstream_finalize_request(r, u,
-                                           NGX_HTTP_CLIENT_CLOSED_REQUEST);
+
+        if (!u->cacheable && !u->store && u->peer.connection) {
+            ngx_http_upstream_finalize_request(r, u,
+                                               NGX_HTTP_CLIENT_CLOSED_REQUEST);
+        }
+
         return;
     }
 
@@ -2486,7 +2490,7 @@ ngx_http_upstream_process_request(ngx_ht
         ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                        "http upstream downstream error");
 
-        if (!u->cacheable && u->peer.connection) {
+        if (!u->cacheable && !u->store && u->peer.connection) {
             ngx_http_upstream_finalize_request(r, u, 0);
         }
     }


More information about the nginx-ru mailing list