Welcome! Log In Create A New Profile

Advanced

[PATCH]Upstream: delete temp file when error in ngx_http_upstream_store().

July 07, 2014 05:22AM
# HG changeset patch
# User FengGu <flygoast@126.com>
# Date 1404723967 -28800
# Mon Jul 07 17:06:07 2014 +0800
# Node ID d1d597fbf6d8e08059a308d8900e5f90def5377a
# Parent a680bf4dddd5c4b106419e3dfb0264815c401275
Upstream: delete temp file when error in ngx_http_upstream_store().


Previously, didn't process the case when ngx_http_map_uri_to_path() returned
NULL. And when error occured, didn't delete the temp file.


diff -r a680bf4dddd5 -r d1d597fbf6d8 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.cSat Jul 05 23:29:47 2014 +0400
+++ b/src/http/ngx_http_upstream.cMon Jul 07 17:06:07 2014 +0800
@@ -3375,14 +3375,16 @@

if (u->conf->store_lengths == NULL) {

- ngx_http_map_uri_to_path(r, &path, &root, 0);
+ if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {
+ goto error;
+ }

} else {
if (ngx_http_script_run(r, &path, u->conf->store_lengths->elts, 0,
u->conf->store_values->elts)
== NULL)
{
- return;
+ goto error;
}
}

@@ -3393,6 +3395,16 @@
tf->file.name.data, path.data);

(void) ngx_ext_rename_file(&tf->file.name, &path, &ext);
+
+ return;
+
+error:
+
+ if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) {
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
+ ngx_delete_file_n " \"%s\" failed",
+ tf->file.name.data);
+ }
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH]Upstream: delete temp file when error in ngx_http_upstream_store().

flygoast 672 July 07, 2014 05:22AM

Re: [PATCH]Upstream: delete temp file when error in ngx_http_upstream_store().

Maxim Dounin 422 July 07, 2014 12:34PM

Re:Re: [PATCH]Upstream: delete temp file when error in ngx_http_upstream_store().

flygoast 364 July 07, 2014 10:30PM

Re: Re: [PATCH]Upstream: delete temp file when error in ngx_http_upstream_store().

Maxim Dounin 310 July 08, 2014 07:48AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 230
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready