comparison src/http/modules/perl/ngx_http_perl_module.c @ 1221:aa653367028e

PERL_SYS_TERM() should be called once on exit only, this fixes the message panic: MUTEX_LOCK (22) [op.c:352]. BEGIN failed--compilation aborted. ... [alert] ... perl_parse() failed: 9 Scalars leaked: 2 on threaded perl during second reconfiguration. PERL_SYS_INIT() should be called once too.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 29 May 2007 18:48:42 +0000
parents efb7d84db340
children 927b06411194 50bdde056629
comparison
equal deleted inserted replaced
1220:91ae88fb2500 1221:aa653367028e
64 static char *ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 64 static char *ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
65 65
66 #if (NGX_HAVE_PERL_MULTIPLICITY) 66 #if (NGX_HAVE_PERL_MULTIPLICITY)
67 static void ngx_http_perl_cleanup_perl(void *data); 67 static void ngx_http_perl_cleanup_perl(void *data);
68 #endif 68 #endif
69
70 static void ngx_http_perl_exit(ngx_cycle_t *cycle);
69 71
70 72
71 static ngx_command_t ngx_http_perl_commands[] = { 73 static ngx_command_t ngx_http_perl_commands[] = {
72 74
73 { ngx_string("perl_modules"), 75 { ngx_string("perl_modules"),
126 NULL, /* init module */ 128 NULL, /* init module */
127 NULL, /* init process */ 129 NULL, /* init process */
128 NULL, /* init thread */ 130 NULL, /* init thread */
129 NULL, /* exit thread */ 131 NULL, /* exit thread */
130 NULL, /* exit process */ 132 NULL, /* exit process */
131 NULL, /* exit master */ 133 ngx_http_perl_exit, /* exit master */
132 NGX_MODULE_V1_PADDING 134 NGX_MODULE_V1_PADDING
133 }; 135 };
134 136
135 137
136 #if (NGX_HTTP_SSI) 138 #if (NGX_HTTP_SSI)
476 return NGX_CONF_OK; 478 return NGX_CONF_OK;
477 } 479 }
478 480
479 #endif 481 #endif
480 482
481 PERL_SYS_INIT(&ngx_argc, &ngx_argv); 483 if (nginx_stash == NULL) {
484 PERL_SYS_INIT(&ngx_argc, &ngx_argv);
485 }
482 486
483 pmcf->perl = ngx_http_perl_create_interpreter(cf, pmcf); 487 pmcf->perl = ngx_http_perl_create_interpreter(cf, pmcf);
484 488
485 if (pmcf->perl == NULL) { 489 if (pmcf->perl == NULL) {
486 PERL_SYS_TERM();
487 return NGX_CONF_ERROR; 490 return NGX_CONF_ERROR;
488 } 491 }
489 492
490 pmcf->nginx = nginx_stash; 493 pmcf->nginx = nginx_stash;
491 494
786 PERL_SET_CONTEXT(perl); 789 PERL_SET_CONTEXT(perl);
787 790
788 (void) perl_destruct(perl); 791 (void) perl_destruct(perl);
789 792
790 perl_free(perl); 793 perl_free(perl);
791
792 PERL_SYS_TERM();
793 } 794 }
794 795
795 #endif 796 #endif
796 797
797 798
999 v->get_handler = ngx_http_perl_variable; 1000 v->get_handler = ngx_http_perl_variable;
1000 v->data = (uintptr_t) pv; 1001 v->data = (uintptr_t) pv;
1001 1002
1002 return NGX_CONF_OK; 1003 return NGX_CONF_OK;
1003 } 1004 }
1005
1006
1007 static void
1008 ngx_http_perl_exit(ngx_cycle_t *cycle)
1009 {
1010 PERL_SYS_TERM();
1011 }