comparison src/core/ngx_cycle.c @ 1740:45db41a0591c

restore environ for perl_destruct()
author Igor Sysoev <igor@sysoev.ru>
date Sun, 16 Dec 2007 11:58:16 +0000
parents e584e946e198
children b56d4b1ebac7
comparison
equal deleted inserted replaced
1739:5b7baef2e11e 1740:45db41a0591c
40 40
41 41
42 ngx_cycle_t * 42 ngx_cycle_t *
43 ngx_init_cycle(ngx_cycle_t *old_cycle) 43 ngx_init_cycle(ngx_cycle_t *old_cycle)
44 { 44 {
45 void *rv; 45 void *rv;
46 u_char *lock_file; 46 char **senv, **env;
47 ngx_uint_t i, n; 47 u_char *lock_file;
48 ngx_log_t *log; 48 ngx_uint_t i, n;
49 ngx_conf_t conf; 49 ngx_log_t *log;
50 ngx_pool_t *pool; 50 ngx_conf_t conf;
51 ngx_cycle_t *cycle, **old; 51 ngx_pool_t *pool;
52 ngx_shm_zone_t *shm_zone, *oshm_zone; 52 ngx_cycle_t *cycle, **old;
53 ngx_slab_pool_t *shpool; 53 ngx_shm_zone_t *shm_zone, *oshm_zone;
54 ngx_list_part_t *part, *opart; 54 ngx_slab_pool_t *shpool;
55 ngx_open_file_t *file; 55 ngx_list_part_t *part, *opart;
56 ngx_listening_t *ls, *nls; 56 ngx_open_file_t *file;
57 ngx_core_conf_t *ccf, *old_ccf; 57 ngx_listening_t *ls, *nls;
58 ngx_core_module_t *module; 58 ngx_core_conf_t *ccf, *old_ccf;
59 ngx_core_module_t *module;
59 60
60 log = old_cycle->log; 61 log = old_cycle->log;
61 62
62 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); 63 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
63 if (pool == NULL) { 64 if (pool == NULL) {
183 return NULL; 184 return NULL;
184 } 185 }
185 cycle->conf_ctx[ngx_modules[i]->index] = rv; 186 cycle->conf_ctx[ngx_modules[i]->index] = rv;
186 } 187 }
187 } 188 }
189
190
191 senv = environ;
188 192
189 193
190 ngx_memzero(&conf, sizeof(ngx_conf_t)); 194 ngx_memzero(&conf, sizeof(ngx_conf_t));
191 /* STUB: init array ? */ 195 /* STUB: init array ? */
192 conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t)); 196 conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t));
692 696
693 ngx_destroy_pool(conf.temp_pool); 697 ngx_destroy_pool(conf.temp_pool);
694 698
695 if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) { 699 if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) {
696 700
701 /*
702 * perl_destruct() frees environ if it is not the same as it was at
703 * perl_construct() time. So we have saved an previous cycle
704 * environment before ngx_conf_parse() where it will be changed.
705 */
706
707 env = environ;
708 environ = senv;
709
697 ngx_destroy_pool(old_cycle->pool); 710 ngx_destroy_pool(old_cycle->pool);
698 cycle->old_cycle = NULL; 711 cycle->old_cycle = NULL;
712
713 environ = env;
699 714
700 return cycle; 715 return cycle;
701 } 716 }
702 717
703 718