[nginx] Core: reverted prefix-based temp files (a9138c35120d).

Roman Arutyunyan arut at nginx.com
Mon Feb 2 18:29:31 UTC 2015


details:   http://hg.nginx.org/nginx/rev/3281de8142f5
branches:  
changeset: 5969:3281de8142f5
user:      Roman Arutyunyan <arut at nginx.com>
date:      Mon Feb 02 21:28:09 2015 +0300
description:
Core: reverted prefix-based temp files (a9138c35120d).

The use_temp_path http cache feature is now implemented using a separate temp
hierarchy in cache directory.  Prefix-based temp files are no longer needed.

diffstat:

 src/core/ngx_file.c |  28 ++++++++--------------------
 src/core/ngx_file.h |   1 -
 2 files changed, 8 insertions(+), 21 deletions(-)

diffs (83 lines):

diff -r 99639bfdfa2a -r 3281de8142f5 src/core/ngx_file.c
--- a/src/core/ngx_file.c	Mon Feb 02 19:38:35 2015 +0300
+++ b/src/core/ngx_file.c	Mon Feb 02 21:28:09 2015 +0300
@@ -111,9 +111,8 @@ ngx_write_chain_to_temp_file(ngx_temp_fi
     ngx_int_t  rc;
 
     if (tf->file.fd == NGX_INVALID_FILE) {
-        rc = ngx_create_temp_file(&tf->file, tf->prefix ? NULL : tf->path,
-                                  tf->pool, tf->persistent, tf->clean,
-                                  tf->access);
+        rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool,
+                                  tf->persistent, tf->clean, tf->access);
 
         if (rc != NGX_OK) {
             return rc;
@@ -133,15 +132,12 @@ ngx_int_t
 ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
     ngx_uint_t persistent, ngx_uint_t clean, ngx_uint_t access)
 {
-    u_char                   *p;
     uint32_t                  n;
     ngx_err_t                 err;
-    ngx_str_t                 prefix;
     ngx_pool_cleanup_t       *cln;
     ngx_pool_cleanup_file_t  *clnf;
 
-    prefix = path ? path->name : file->name;
-    file->name.len = prefix.len + 1 + (path ? path->len : 0) + 10;
+    file->name.len = path->name.len + 1 + path->len + 10;
 
     file->name.data = ngx_pnalloc(pool, file->name.len + 1);
     if (file->name.data == NULL) {
@@ -154,14 +150,7 @@ ngx_create_temp_file(ngx_file_t *file, n
     }
 #endif
 
-    p = ngx_cpymem(file->name.data, prefix.data, prefix.len);
-
-    if (path) {
-        p += 1 + path->len;
-
-    } else {
-        *p++ = '.';
-    }
+    ngx_memcpy(file->name.data, path->name.data, path->name.len);
 
     n = (uint32_t) ngx_next_temp_number(0);
 
@@ -171,11 +160,10 @@ ngx_create_temp_file(ngx_file_t *file, n
     }
 
     for ( ;; ) {
-        (void) ngx_sprintf(p, "%010uD%Z", n);
+        (void) ngx_sprintf(file->name.data + path->name.len + 1 + path->len,
+                           "%010uD%Z", n);
 
-        if (path) {
-            ngx_create_hashed_filename(path, file->name.data, file->name.len);
-        }
+        ngx_create_hashed_filename(path, file->name.data, file->name.len);
 
         ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
                        "hashed path: %s", file->name.data);
@@ -204,7 +192,7 @@ ngx_create_temp_file(ngx_file_t *file, n
             continue;
         }
 
-        if ((path == NULL) || (path->level[0] == 0) || (err != NGX_ENOPATH)) {
+        if ((path->level[0] == 0) || (err != NGX_ENOPATH)) {
             ngx_log_error(NGX_LOG_CRIT, file->log, err,
                           ngx_open_tempfile_n " \"%s\" failed",
                           file->name.data);
diff -r 99639bfdfa2a -r 3281de8142f5 src/core/ngx_file.h
--- a/src/core/ngx_file.h	Mon Feb 02 19:38:35 2015 +0300
+++ b/src/core/ngx_file.h	Mon Feb 02 21:28:09 2015 +0300
@@ -71,7 +71,6 @@ typedef struct {
     unsigned                   log_level:8;
     unsigned                   persistent:1;
     unsigned                   clean:1;
-    unsigned                   prefix:1;
 } ngx_temp_file_t;
 
 



More information about the nginx-devel mailing list