comparison src/http/ngx_http_upstream.c @ 5770:9de5820bb3e0

Upstream: ngx_http_upstream_store() error handling fixes. Previously, ngx_http_map_uri_to_path() errors were not checked in ngx_http_upstream_store(). Moreover, in case of errors temporary files were not deleted, as u->store was set to 0, preventing cleanup code in ngx_http_upstream_finalize_request() from removing them. With this patch, u->store is set to 0 only if there were no errors. Reported by Feng Gu.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 18 Jul 2014 20:11:40 +0400
parents c5ec6944de98
children 9bf58a3da25b
comparison
equal deleted inserted replaced
5769:e0aa54a4357e 5770:9de5820bb3e0
3251 && (p->upstream_done || p->length == -1) 3251 && (p->upstream_done || p->length == -1)
3252 && (u->headers_in.content_length_n == -1 3252 && (u->headers_in.content_length_n == -1
3253 || u->headers_in.content_length_n == tf->offset)) 3253 || u->headers_in.content_length_n == tf->offset))
3254 { 3254 {
3255 ngx_http_upstream_store(r, u); 3255 ngx_http_upstream_store(r, u);
3256 u->store = 0;
3257 } 3256 }
3258 } 3257 }
3259 } 3258 }
3260 3259
3261 #if (NGX_HTTP_CACHE) 3260 #if (NGX_HTTP_CACHE)
3373 } 3372 }
3374 } 3373 }
3375 3374
3376 if (u->conf->store_lengths == NULL) { 3375 if (u->conf->store_lengths == NULL) {
3377 3376
3378 ngx_http_map_uri_to_path(r, &path, &root, 0); 3377 if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {
3378 return;
3379 }
3379 3380
3380 } else { 3381 } else {
3381 if (ngx_http_script_run(r, &path, u->conf->store_lengths->elts, 0, 3382 if (ngx_http_script_run(r, &path, u->conf->store_lengths->elts, 0,
3382 u->conf->store_values->elts) 3383 u->conf->store_values->elts)
3383 == NULL) 3384 == NULL)
3391 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 3392 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
3392 "upstream stores \"%s\" to \"%s\"", 3393 "upstream stores \"%s\" to \"%s\"",
3393 tf->file.name.data, path.data); 3394 tf->file.name.data, path.data);
3394 3395
3395 (void) ngx_ext_rename_file(&tf->file.name, &path, &ext); 3396 (void) ngx_ext_rename_file(&tf->file.name, &path, &ext);
3397
3398 u->store = 0;
3396 } 3399 }
3397 3400
3398 3401
3399 static void 3402 static void
3400 ngx_http_upstream_dummy_handler(ngx_http_request_t *r, ngx_http_upstream_t *u) 3403 ngx_http_upstream_dummy_handler(ngx_http_request_t *r, ngx_http_upstream_t *u)