[nginx] Fixed google_perftools_profiles to be resolved from prefix.

Maxim Dounin mdounin at mdounin.ru
Fri Oct 31 20:43:14 UTC 2025


details:   http://freenginx.org/hg/nginx/rev/33c3d7927c13
branches:  
changeset: 9431:33c3d7927c13
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri Oct 31 08:07:57 2025 +0300
description:
Fixed google_perftools_profiles to be resolved from prefix.

Previously, relative values of google_perftools_profiles set in the
configuration were not processed with ngx_conf_full_name() and therefore
resolved from the process current working directory, leading to changes
in behaviour depending on the current directory during startup.  This also
differs from the expected behaviour of configuration directives, where
relative paths are expected to be resolved either from prefix or from
configuration prefix.

Fix is to use ngx_conf_full_name() to resolve working_directory from prefix.

diffstat:

 src/misc/ngx_google_perftools_module.c |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (42 lines):

diff --git a/src/misc/ngx_google_perftools_module.c b/src/misc/ngx_google_perftools_module.c
--- a/src/misc/ngx_google_perftools_module.c
+++ b/src/misc/ngx_google_perftools_module.c
@@ -19,6 +19,7 @@ void ProfilerRegisterThread(void);
 
 
 static void *ngx_google_perftools_create_conf(ngx_cycle_t *cycle);
+static char *ngx_google_perftools_init_conf(ngx_cycle_t *cycle, void *conf);
 static ngx_int_t ngx_google_perftools_worker(ngx_cycle_t *cycle);
 
 
@@ -43,7 +44,7 @@ static ngx_command_t  ngx_google_perftoo
 static ngx_core_module_t  ngx_google_perftools_module_ctx = {
     ngx_string("google_perftools"),
     ngx_google_perftools_create_conf,
-    NULL
+    ngx_google_perftools_init_conf
 };
 
 
@@ -83,6 +84,21 @@ ngx_google_perftools_create_conf(ngx_cyc
 }
 
 
+static char *
+ngx_google_perftools_init_conf(ngx_cycle_t *cycle, void *conf)
+{
+    ngx_google_perftools_conf_t  *gptcf = conf;
+
+    if (gptcf->profiles.len) {
+        if (ngx_conf_full_name(cycle, &gptcf->profiles, 0) != NGX_OK) {
+            return NGX_CONF_ERROR;
+        }
+    }
+
+    return NGX_CONF_OK;
+}
+
+
 static ngx_int_t
 ngx_google_perftools_worker(ngx_cycle_t *cycle)
 {


More information about the nginx-devel mailing list