[PATCH 3 of 5] Fixed google_perftools_profiles to be resolved from prefix

Maxim Dounin mdounin at mdounin.ru
Fri Oct 24 01:42:39 UTC 2025


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1761147233 -10800
#      Wed Oct 22 18:33:53 2025 +0300
# Node ID d8642f2ac14d1e5bb73a231c0898e1a1735beb62
# Parent  df1f91eafba30d5ed1c9ad80d771be043d731e9a
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.

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