Mercurial > hg > nginx-quic
comparison src/http/modules/perl/ngx_http_perl_module.c @ 908:82adc19b4b4d
axe ngx_http_perl_cleanup_sv(): all SVs should be freed
by perl_free() in ngx_http_perl_cleanup_perl()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 12 Dec 2006 20:06:04 +0000 |
parents | 98afa13ea7e5 |
children | 73c66ed9a9cd |
comparison
equal
deleted
inserted
replaced
907:424636f52f44 | 908:82adc19b4b4d |
---|---|
60 void *child); | 60 void *child); |
61 static char *ngx_http_perl_require(ngx_conf_t *cf, ngx_command_t *cmd, | 61 static char *ngx_http_perl_require(ngx_conf_t *cf, ngx_command_t *cmd, |
62 void *conf); | 62 void *conf); |
63 static char *ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 63 static char *ngx_http_perl(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); | 64 static char *ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
65 static void ngx_http_perl_cleanup_sv(void *data); | |
66 | 65 |
67 #if (NGX_HAVE_PERL_MULTIPLICITY) | 66 #if (NGX_HAVE_PERL_MULTIPLICITY) |
68 static void ngx_http_perl_cleanup_perl(void *data); | 67 static void ngx_http_perl_cleanup_perl(void *data); |
69 #endif | 68 #endif |
70 | 69 |
756 } | 755 } |
757 | 756 |
758 #endif | 757 #endif |
759 | 758 |
760 | 759 |
761 static void | |
762 ngx_http_perl_cleanup_sv(void *data) | |
763 { | |
764 ngx_http_perl_cleanup_t *cln = data; | |
765 | |
766 dTHXa(cln->perl); | |
767 PERL_SET_CONTEXT(cln->perl); | |
768 | |
769 SvREFCNT_dec(cln->sv); | |
770 } | |
771 | |
772 | |
773 static ngx_int_t | 760 static ngx_int_t |
774 ngx_http_perl_preconfiguration(ngx_conf_t *cf) | 761 ngx_http_perl_preconfiguration(ngx_conf_t *cf) |
775 { | 762 { |
776 #if (NGX_HTTP_SSI) | 763 #if (NGX_HTTP_SSI) |
777 ngx_int_t rc; | 764 ngx_int_t rc; |
858 ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 845 ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
859 { | 846 { |
860 ngx_http_perl_loc_conf_t *plcf = conf; | 847 ngx_http_perl_loc_conf_t *plcf = conf; |
861 | 848 |
862 ngx_str_t *value; | 849 ngx_str_t *value; |
863 ngx_pool_cleanup_t *cln; | |
864 ngx_http_perl_cleanup_t *pcln; | |
865 ngx_http_core_loc_conf_t *clcf; | 850 ngx_http_core_loc_conf_t *clcf; |
866 ngx_http_perl_main_conf_t *pmcf; | 851 ngx_http_perl_main_conf_t *pmcf; |
867 | 852 |
868 value = cf->args->elts; | 853 value = cf->args->elts; |
869 | 854 |
879 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { | 864 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { |
880 return NGX_CONF_ERROR; | 865 return NGX_CONF_ERROR; |
881 } | 866 } |
882 } | 867 } |
883 | 868 |
884 cln = ngx_pool_cleanup_add(cf->pool, sizeof(ngx_http_perl_cleanup_t)); | |
885 if (cln == NULL) { | |
886 return NGX_CONF_ERROR; | |
887 } | |
888 | |
889 plcf->handler = value[1]; | 869 plcf->handler = value[1]; |
890 | 870 |
891 { | 871 { |
892 | 872 |
893 dTHXa(pmcf->perl); | 873 dTHXa(pmcf->perl); |
905 plcf->sub = newSVpvn((char *) value[1].data, value[1].len); | 885 plcf->sub = newSVpvn((char *) value[1].data, value[1].len); |
906 } | 886 } |
907 | 887 |
908 } | 888 } |
909 | 889 |
910 cln->handler = ngx_http_perl_cleanup_sv; | |
911 pcln = cln->data; | |
912 pcln->sv = plcf->sub; | |
913 pcln->perl = pmcf->perl; | |
914 | |
915 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); | 890 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
916 clcf->handler = ngx_http_perl_handler; | 891 clcf->handler = ngx_http_perl_handler; |
917 | 892 |
918 return NGX_CONF_OK; | 893 return NGX_CONF_OK; |
919 } | 894 } |
922 static char * | 897 static char * |
923 ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 898 ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
924 { | 899 { |
925 ngx_int_t index; | 900 ngx_int_t index; |
926 ngx_str_t *value; | 901 ngx_str_t *value; |
927 ngx_pool_cleanup_t *cln; | |
928 ngx_http_variable_t *v; | 902 ngx_http_variable_t *v; |
929 ngx_http_perl_cleanup_t *pcln; | |
930 ngx_http_perl_variable_t *pv; | 903 ngx_http_perl_variable_t *pv; |
931 ngx_http_perl_main_conf_t *pmcf; | 904 ngx_http_perl_main_conf_t *pmcf; |
932 | 905 |
933 value = cf->args->elts; | 906 value = cf->args->elts; |
934 | 907 |
962 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { | 935 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { |
963 return NGX_CONF_ERROR; | 936 return NGX_CONF_ERROR; |
964 } | 937 } |
965 } | 938 } |
966 | 939 |
967 cln = ngx_pool_cleanup_add(cf->pool, sizeof(ngx_http_perl_cleanup_t)); | |
968 if (cln == NULL) { | |
969 return NGX_CONF_ERROR; | |
970 } | |
971 | |
972 pv->handler = value[2]; | 940 pv->handler = value[2]; |
973 | 941 |
974 { | 942 { |
975 | 943 |
976 dTHXa(pmcf->perl); | 944 dTHXa(pmcf->perl); |
988 pv->sub = newSVpvn((char *) value[2].data, value[2].len); | 956 pv->sub = newSVpvn((char *) value[2].data, value[2].len); |
989 } | 957 } |
990 | 958 |
991 } | 959 } |
992 | 960 |
993 cln->handler = ngx_http_perl_cleanup_sv; | |
994 pcln = cln->data; | |
995 pcln->sv = pv->sub; | |
996 pcln->perl = pmcf->perl; | |
997 | |
998 v->get_handler = ngx_http_perl_variable; | 961 v->get_handler = ngx_http_perl_variable; |
999 v->data = (uintptr_t) pv; | 962 v->data = (uintptr_t) pv; |
1000 | 963 |
1001 return NGX_CONF_OK; | 964 return NGX_CONF_OK; |
1002 } | 965 } |