diff src/core/ngx_cycle.c @ 356:b743d290eb3b NGINX_0_6_22

nginx 0.6.22 *) Change: now all ngx_http_perl_module methods return values copied to perl's allocated memory. *) Bugfix: if nginx was built with ngx_http_perl_module, the perl before 5.8.6 was used, and perl supported threads, then during reconfiguration the master process aborted; bug appeared in 0.5.9. Thanks to Boris Zhmurov. *) Bugfix: the ngx_http_perl_module methods may get invalid values of the regex captures. *) Bugfix: a segmentation fault occurred in worker process, if the $r->has_request_body() method was called for a request whose small request body was already received. *) Bugfix: large_client_header_buffers did not freed before going to keep-alive state. Thanks to Olexander Shtepa. *) Bugfix: the last address was missed in the $upstream_addr variable; bug appeared in 0.6.18. *) Bugfix: the "fastcgi_catch_stderr" directive did return error code; now it returns 502 code, that can be rerouted to a next server using the "fastcgi_next_upstream invalid_header" directive. *) Bugfix: a segmentation fault occurred in master process if the "fastcgi_catch_stderr" directive was used; bug appeared in 0.6.10. Thanks to Manlio Perillo.
author Igor Sysoev <http://sysoev.ru>
date Wed, 19 Dec 2007 00:00:00 +0300
parents 2ceaee987f37
children edf1cb6c328e
line wrap: on
line diff
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -42,20 +42,21 @@ static ngx_str_t  error_log = ngx_null_s
 ngx_cycle_t *
 ngx_init_cycle(ngx_cycle_t *old_cycle)
 {
-    void               *rv;
-    u_char             *lock_file;
-    ngx_uint_t          i, n;
-    ngx_log_t          *log;
-    ngx_conf_t          conf;
-    ngx_pool_t         *pool;
-    ngx_cycle_t        *cycle, **old;
-    ngx_shm_zone_t     *shm_zone, *oshm_zone;
-    ngx_slab_pool_t    *shpool;
-    ngx_list_part_t    *part, *opart;
-    ngx_open_file_t    *file;
-    ngx_listening_t    *ls, *nls;
-    ngx_core_conf_t    *ccf, *old_ccf;
-    ngx_core_module_t  *module;
+    void                *rv;
+    char               **senv, **env;
+    u_char              *lock_file;
+    ngx_uint_t           i, n;
+    ngx_log_t           *log;
+    ngx_conf_t           conf;
+    ngx_pool_t          *pool;
+    ngx_cycle_t         *cycle, **old;
+    ngx_shm_zone_t      *shm_zone, *oshm_zone;
+    ngx_slab_pool_t     *shpool;
+    ngx_list_part_t     *part, *opart;
+    ngx_open_file_t     *file;
+    ngx_listening_t     *ls, *nls;
+    ngx_core_conf_t     *ccf, *old_ccf;
+    ngx_core_module_t   *module;
 
     log = old_cycle->log;
 
@@ -187,6 +188,9 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
     }
 
 
+    senv = environ;
+
+
     ngx_memzero(&conf, sizeof(ngx_conf_t));
     /* STUB: init array ? */
     conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t));
@@ -694,9 +698,20 @@ old_shm_zone_done:
 
     if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) {
 
+        /*
+         * perl_destruct() frees environ if it is not the same as it was at
+         * perl_construct() time.  So we have saved an previous cycle
+         * environment before ngx_conf_parse() where it will be changed.
+         */
+
+        env = environ;
+        environ = senv;
+
         ngx_destroy_pool(old_cycle->pool);
         cycle->old_cycle = NULL;
 
+        environ = env;
+
         return cycle;
     }
 
@@ -938,9 +953,6 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx
     ngx_uint_t        i;
     ngx_list_part_t  *part;
     ngx_open_file_t  *file;
-#if !(NGX_WIN32)
-    ngx_file_info_t   fi;
-#endif
 
     part = &cycle->open_files.part;
     file = part->elts;
@@ -996,6 +1008,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx
         }
 #else
         if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
+            ngx_file_info_t  fi;
 
             if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) {
                 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,