comparison src/http/modules/perl/ngx_http_perl_module.c @ 2713:b4d8aef4a1ad

fix segfault if no http section is defined in confguraiton, the bug has been introduced in r1259
author Igor Sysoev <igor@sysoev.ru>
date Wed, 15 Apr 2009 20:26:33 +0000
parents 722b5aff05ae
children 4dd1773990db
comparison
equal deleted inserted replaced
2712:41f993457021 2713:b4d8aef4a1ad
1039 { 1039 {
1040 ngx_http_perl_main_conf_t *pmcf; 1040 ngx_http_perl_main_conf_t *pmcf;
1041 1041
1042 pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module); 1042 pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module);
1043 1043
1044 if (pmcf) {
1045 dTHXa(pmcf->perl);
1046 PERL_SET_CONTEXT(pmcf->perl);
1047
1048 /* set worker's $$ */
1049
1050 sv_setiv(GvSV(gv_fetchpv("$", TRUE, SVt_PV)), (I32) ngx_pid);
1051 }
1052
1053 return NGX_OK;
1054 }
1055
1056
1057 static void
1058 ngx_http_perl_exit(ngx_cycle_t *cycle)
1059 {
1060 ngx_http_perl_main_conf_t *pmcf;
1061
1062 pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module);
1063
1044 { 1064 {
1045 1065
1046 dTHXa(pmcf->perl); 1066 dTHXa(pmcf->perl);
1047 PERL_SET_CONTEXT(pmcf->perl); 1067 PERL_SET_CONTEXT(pmcf->perl);
1048 1068
1049 /* set worker's $$ */
1050
1051 sv_setiv(GvSV(gv_fetchpv("$", TRUE, SVt_PV)), (I32) ngx_pid);
1052
1053 }
1054
1055 return NGX_OK;
1056 }
1057
1058
1059 static void
1060 ngx_http_perl_exit(ngx_cycle_t *cycle)
1061 {
1062 ngx_http_perl_main_conf_t *pmcf;
1063
1064 pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module);
1065
1066 {
1067
1068 dTHXa(pmcf->perl);
1069 PERL_SET_CONTEXT(pmcf->perl);
1070
1071 PERL_SYS_TERM(); 1069 PERL_SYS_TERM();
1072 1070
1073 } 1071 }
1074 } 1072 }