Mercurial > hg > nginx-quic
comparison src/http/ngx_http_upstream.c @ 4469:24c0dca04eb9
Fix for proxy_store leaving temporary files for subrequests.
Temporary files might not be removed if the "proxy_store" or "fastcgi_store"
directives were used for subrequests (e.g. ssi includes) and client closed
connection prematurely.
Non-active subrequests are finalized out of the control of the upstream
module when client closes a connection. As a result, the code to remove
unfinished temporary files in ngx_http_upstream_process_request() wasn't
executed.
Fix is to move relevant code into ngx_http_upstream_finalize_request() which
is called in all cases, either directly or via the cleanup handler.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 13 Feb 2012 15:28:19 +0000 |
parents | 7bf3b68239a3 |
children | 41f640a693de |
comparison
equal
deleted
inserted
replaced
4468:93dd50a9dc70 | 4469:24c0dca04eb9 |
---|---|
2649 | 2649 |
2650 | 2650 |
2651 static void | 2651 static void |
2652 ngx_http_upstream_process_request(ngx_http_request_t *r) | 2652 ngx_http_upstream_process_request(ngx_http_request_t *r) |
2653 { | 2653 { |
2654 ngx_uint_t del; | |
2655 ngx_temp_file_t *tf; | 2654 ngx_temp_file_t *tf; |
2656 ngx_event_pipe_t *p; | 2655 ngx_event_pipe_t *p; |
2657 ngx_http_upstream_t *u; | 2656 ngx_http_upstream_t *u; |
2658 | 2657 |
2659 u = r->upstream; | 2658 u = r->upstream; |
2661 | 2660 |
2662 if (u->peer.connection) { | 2661 if (u->peer.connection) { |
2663 | 2662 |
2664 if (u->store) { | 2663 if (u->store) { |
2665 | 2664 |
2666 del = p->upstream_error; | |
2667 | |
2668 tf = u->pipe->temp_file; | |
2669 | |
2670 if (p->upstream_eof || p->upstream_done) { | 2665 if (p->upstream_eof || p->upstream_done) { |
2666 | |
2667 tf = u->pipe->temp_file; | |
2671 | 2668 |
2672 if (u->headers_in.status_n == NGX_HTTP_OK | 2669 if (u->headers_in.status_n == NGX_HTTP_OK |
2673 && (u->headers_in.content_length_n == -1 | 2670 && (u->headers_in.content_length_n == -1 |
2674 || (u->headers_in.content_length_n == tf->offset))) | 2671 || (u->headers_in.content_length_n == tf->offset))) |
2675 { | 2672 { |
2676 ngx_http_upstream_store(r, u); | 2673 ngx_http_upstream_store(r, u); |
2677 | 2674 u->store = 0; |
2678 } else { | |
2679 del = 1; | |
2680 } | |
2681 } | |
2682 | |
2683 if (del && tf->file.fd != NGX_INVALID_FILE) { | |
2684 | |
2685 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) { | |
2686 | |
2687 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | |
2688 ngx_delete_file_n " \"%s\" failed", | |
2689 u->pipe->temp_file->file.name.data); | |
2690 } | 2675 } |
2691 } | 2676 } |
2692 } | 2677 } |
2693 | 2678 |
2694 #if (NGX_HTTP_CACHE) | 2679 #if (NGX_HTTP_CACHE) |
3045 | 3030 |
3046 if (u->pipe && u->pipe->temp_file) { | 3031 if (u->pipe && u->pipe->temp_file) { |
3047 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 3032 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
3048 "http upstream temp fd: %d", | 3033 "http upstream temp fd: %d", |
3049 u->pipe->temp_file->file.fd); | 3034 u->pipe->temp_file->file.fd); |
3035 } | |
3036 | |
3037 if (u->store && u->pipe && u->pipe->temp_file | |
3038 && u->pipe->temp_file->file.fd != NGX_INVALID_FILE) | |
3039 { | |
3040 if (ngx_delete_file(u->pipe->temp_file->file.name.data) | |
3041 == NGX_FILE_ERROR) | |
3042 { | |
3043 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, | |
3044 ngx_delete_file_n " \"%s\" failed", | |
3045 u->pipe->temp_file->file.name.data); | |
3046 } | |
3050 } | 3047 } |
3051 | 3048 |
3052 #if (NGX_HTTP_CACHE) | 3049 #if (NGX_HTTP_CACHE) |
3053 | 3050 |
3054 if (r->cache) { | 3051 if (r->cache) { |