<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><div># HG changeset patch</div><div># User FengGu <flygoast@126.com></div><div># Date 1404723967 -28800</div><div>#      Mon Jul 07 17:06:07 2014 +0800</div><div># Node ID d1d597fbf6d8e08059a308d8900e5f90def5377a</div><div># Parent  a680bf4dddd5c4b106419e3dfb0264815c401275</div><div>Upstream: delete temp file when error in ngx_http_upstream_store().</div><div><br></div><div>Previously, didn't process the case when ngx_http_map_uri_to_path() returned</div><div>NULL. And when error occured, didn't delete the temp file.</div><div><br></div><div>diff -r a680bf4dddd5 -r d1d597fbf6d8 src/http/ngx_http_upstream.c</div><div>--- a/src/http/ngx_http_upstream.c<span class="Apple-tab-span" style="white-space:pre">       </span>Sat Jul 05 23:29:47 2014 +0400</div><div>+++ b/src/http/ngx_http_upstream.c<span class="Apple-tab-span" style="white-space:pre">     </span>Mon Jul 07 17:06:07 2014 +0800</div><div>@@ -3375,14 +3375,16 @@</div><div> </div><div>     if (u->conf->store_lengths == NULL) {</div><div> </div><div>-        ngx_http_map_uri_to_path(r, &path, &root, 0);</div><div>+        if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {</div><div>+            goto error;</div><div>+        }</div><div> </div><div>     } else {</div><div>         if (ngx_http_script_run(r, &path, u->conf->store_lengths->elts, 0,</div><div>                                 u->conf->store_values->elts)</div><div>             == NULL)</div><div>         {</div><div>-            return;</div><div>+            goto error;</div><div>         }</div><div>     }</div><div> </div><div>@@ -3393,6 +3395,16 @@</div><div>                    tf->file.name.data, path.data);</div><div> </div><div>     (void) ngx_ext_rename_file(&tf->file.name, &path, &ext);</div><div>+</div><div>+    return;</div><div>+</div><div>+error:</div><div>+</div><div>+    if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) {</div><div>+        ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,</div><div>+                      ngx_delete_file_n " \"%s\" failed",</div><div>+                      tf->file.name.data);</div><div>+    }</div><div> }</div><div> </div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>