]> git.kaiwu.me - nginx.git/commitdiff
Backed out f1a91825730a and 7094bd12c1ff.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 20 Aug 2013 17:11:19 +0000 (21:11 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 20 Aug 2013 17:11:19 +0000 (21:11 +0400)
While ngx_get_full_name() might have a bit more descriptive arguments,
the ngx_conf_full_name() is generally easier to use when parsing
configuration and limits exposure of cycle->prefix / cycle->conf_prefix
details.

13 files changed:
src/core/nginx.c
src/core/ngx_conf_file.c
src/core/ngx_conf_file.h
src/core/ngx_file.c
src/event/ngx_event_openssl.c
src/event/ngx_event_openssl_stapling.c
src/http/modules/ngx_http_geo_module.c
src/http/modules/ngx_http_log_module.c
src/http/modules/ngx_http_xslt_filter_module.c
src/http/modules/perl/ngx_http_perl_module.c
src/http/ngx_http_core_module.c
src/http/ngx_http_file_cache.c
src/http/ngx_http_script.c

index 9cabac1e69c269c58307117b45aa200f9052d035..4cc80826edcb38a2487c914e9fe16a49c266d796 100644 (file)
@@ -897,9 +897,7 @@ ngx_process_options(ngx_cycle_t *cycle)
         ngx_str_set(&cycle->conf_file, NGX_CONF_PATH);
     }
 
-    if (ngx_get_full_name(cycle->pool, &cycle->prefix, &cycle->conf_file)
-        != NGX_OK)
-    {
+    if (ngx_conf_full_name(cycle, &cycle->conf_file, 0) != NGX_OK) {
         return NGX_ERROR;
     }
 
@@ -1015,7 +1013,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
         ngx_str_set(&ccf->pid, NGX_PID_PATH);
     }
 
-    if (ngx_get_full_name(cycle->pool, &cycle->prefix, &ccf->pid) != NGX_OK) {
+    if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
@@ -1063,9 +1061,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
         ngx_str_set(&ccf->lock_file, NGX_LOCK_PATH);
     }
 
-    if (ngx_get_full_name(cycle->pool, &cycle->prefix, &ccf->lock_file)
-        != NGX_OK)
-    {
+    if (ngx_conf_full_name(cycle, &ccf->lock_file, 0) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
index afa27d76c74c05cf4d46a021bd6d1a1c8f60b332..6cfb5d58db3dc3996d25b0472758f1fbf0a56ffd 100644 (file)
@@ -747,7 +747,7 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, &file) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
@@ -797,6 +797,16 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 }
 
 
+ngx_int_t
+ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
+{
+    return ngx_get_full_name(cycle->pool,
+                             conf_prefix ? &cycle->conf_prefix:
+                                           &cycle->prefix,
+                             name);
+}
+
+
 ngx_open_file_t *
 ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
 {
@@ -812,7 +822,7 @@ ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
     if (name->len) {
         full = *name;
 
-        if (ngx_get_full_name(cycle->pool, &cycle->prefix, &full) != NGX_OK) {
+        if (ngx_conf_full_name(cycle, &full, 0) != NGX_OK) {
             return NULL;
         }
 
index f0a12d41ff2976b3e06812bd803c3757289a4ad7..d73a6c8bf55d733bf2dce2f43f66688ba3fe87f4 100644 (file)
@@ -311,6 +311,8 @@ char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
 char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
 
+ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name,
+    ngx_uint_t conf_prefix);
 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
 void ngx_cdecl ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf,
     ngx_err_t err, const char *fmt, ...);
index 049b8767c89346a12045c70034d333a65a3c3203..28e8871ece477d7e1c7984e6d4a77b1bc226ecc6 100644 (file)
@@ -355,9 +355,7 @@ ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         path->name.len--;
     }
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &path->name)
-        != NGX_OK)
-    {
+    if (ngx_conf_full_name(cf->cycle, &path->name, 0) != NGX_OK) {
         return NULL;
     }
 
@@ -411,9 +409,7 @@ ngx_conf_merge_path_value(ngx_conf_t *cf, ngx_path_t **path, ngx_path_t *prev,
 
     (*path)->name = init->name;
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &(*path)->name)
-        != NGX_OK)
-    {
+    if (ngx_conf_full_name(cf->cycle, &(*path)->name, 0) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
index 1459eeab90893970103ca511a89817a695da80a7..50746e7ac257eca79f454c524d849370a3d0f06e 100644 (file)
@@ -240,7 +240,7 @@ ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
     X509    *x509;
     u_long   n;
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, cert) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, cert, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
@@ -319,7 +319,7 @@ ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
 
     BIO_free(bio);
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, key) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, key, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
@@ -350,7 +350,7 @@ ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
         return NGX_OK;
     }
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, cert) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, cert, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
@@ -394,7 +394,7 @@ ngx_ssl_trusted_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
         return NGX_OK;
     }
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, cert) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, cert, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
@@ -421,7 +421,7 @@ ngx_ssl_crl(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *crl)
         return NGX_OK;
     }
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, crl) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, crl, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
@@ -587,7 +587,7 @@ ngx_ssl_dhparam(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *file)
         return NGX_OK;
     }
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, file) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, file, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
index f02eab67788ed201b0cf62761f9e6e152f9c017d..77076141c636ca6602df096280643fbaadc1ea04 100644 (file)
@@ -197,7 +197,7 @@ ngx_ssl_stapling_file(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *file)
 
     staple = SSL_CTX_get_ex_data(ssl->ctx, ngx_ssl_stapling_index);
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, file) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, file, 1) != NGX_OK) {
         return NGX_ERROR;
     }
 
index 711871b6c0a5d167c1b6f0a828679db6a06a38f7..34c3b190d188826b56ae424ec07150f585ac0833 100644 (file)
@@ -1327,7 +1327,7 @@ ngx_http_geo_include(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx,
 
     ngx_sprintf(file.data, "%V.bin%Z", name);
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->conf_prefix, &file) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
index 505ae3b221521d6301596a850d03e100807d9fbc..aa6a3fceee95de123ebde336946c84c5380a9f5c 100644 (file)
@@ -1134,9 +1134,7 @@ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         }
 
     } else {
-        if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &value[1])
-            != NGX_OK)
-        {
+        if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
             return NGX_CONF_ERROR;
         }
 
index 6bf38285b807509de4c606f759796af173cbe16d..9e85693bcc48e9a0440536c6071292f2a463ee15 100644 (file)
@@ -892,7 +892,7 @@ ngx_http_xslt_stylesheet(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     ngx_memzero(sheet, sizeof(ngx_http_xslt_sheet_t));
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &value[1]) != NGX_OK) {
+    if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
index a8a418422424767029c47d89018e055b9c992168..90e32e80efa5295bd4460292d82b564e9f399059 100644 (file)
@@ -485,9 +485,7 @@ ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
     if (pmcf->modules != NGX_CONF_UNSET_PTR) {
         m = pmcf->modules->elts;
         for (i = 0; i < pmcf->modules->nelts; i++) {
-            if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &m[i])
-                != NGX_OK)
-            {
+            if (ngx_conf_full_name(cf->cycle, &m[i], 0) != NGX_OK) {
                 return NGX_CONF_ERROR;
             }
         }
index 5273fe32cf1fda21c973bf3b06c8cc04be744840..ffe7fb4fe7ce51cc26af186de60186688d723eef 100644 (file)
@@ -3686,9 +3686,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
         if (prev->root.data == NULL) {
             ngx_str_set(&conf->root, "html");
 
-            if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &conf->root)
-                != NGX_OK)
-            {
+            if (ngx_conf_full_name(cf->cycle, &conf->root, 0) != NGX_OK) {
                 return NGX_CONF_ERROR;
             }
         }
@@ -4430,9 +4428,7 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     }
 
     if (clcf->root.data[0] != '$') {
-        if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &clcf->root)
-            != NGX_OK)
-        {
+        if (ngx_conf_full_name(cf->cycle, &clcf->root, 0) != NGX_OK) {
             return NGX_CONF_ERROR;
         }
     }
index 0b90c41503c1c9834e0e49d40d16e05a23c386c5..eacca595aea3749eb4e3368d180a4b8ba93e96fc 100644 (file)
@@ -1626,9 +1626,7 @@ ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         cache->path->name.len--;
     }
 
-    if (ngx_get_full_name(cf->pool, &cf->cycle->prefix, &cache->path->name)
-        != NGX_OK)
-    {
+    if (ngx_conf_full_name(cf->cycle, &cache->path->name, 0) != NGX_OK) {
         return NGX_CONF_ERROR;
     }
 
index 7af48ee00850f7cf9c55a5b1c1f1650cf54ad6db..1da793b8f08659af4b0658c44e386dcd14964a42 100644 (file)
@@ -131,12 +131,7 @@ ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv)
     if ((v->len == 0 || v->data[0] != '$')
         && (ccv->conf_prefix || ccv->root_prefix))
     {
-        if (ngx_get_full_name(ccv->cf->pool,
-                              ccv->conf_prefix ? &ccv->cf->cycle->conf_prefix:
-                                                 &ccv->cf->cycle->prefix,
-                              v)
-            != NGX_OK)
-        {
+        if (ngx_conf_full_name(ccv->cf->cycle, v, ccv->conf_prefix) != NGX_OK) {
             return NGX_ERROR;
         }