Mercurial > hg > nginx-vendor-0-7
diff src/http/modules/perl/ngx_http_perl_module.c @ 502:89dc5654117c NGINX_0_7_63
nginx 0.7.63
*) Security: now "/../" are disabled in "Destination" request header
line.
*) Change: minimum supported OpenSSL version is 0.9.7.
*) Change: the "ask" parameter of the "ssl_verify_client" directive was
changed to the "optional" parameter and now it checks a client
certificate if it was offered.
Thanks to Brice Figureau.
*) Feature: now the "-V" switch shows TLS SNI support.
*) Feature: the $ssl_client_verify variable.
Thanks to Brice Figureau.
*) Feature: the "ssl_crl" directive.
Thanks to Brice Figureau.
*) Bugfix: the $ssl_client_cert variable usage corrupted memory; the
bug had appeared in 0.7.7.
Thanks to Sergey Zhuravlev.
*) Feature: now the start cache loader runs in a separate process; this
should improve large caches handling.
*) Feature: now temporary files and permanent storage area may reside
at different file systems.
*) Bugfix: nginx counted incorrectly disk cache size.
*) Change: now directive "gzip_disable msie6" does not disable gzipping
for MSIE 6.0 SV1.
*) Bugfix: nginx always added "Vary: Accept-Encoding" response header
line, if both "gzip_static" and "gzip_vary" were on.
*) Feature: the "proxy" parameter of the "geo" directive.
*) Feature: the ngx_http_geoip_module.
*) Feature: the "limit_rate_after" directive.
Thanks to Ivan Debnar.
*) Feature: the "limit_req_log_level" and "limit_conn_log_level"
directives.
*) Bugfix: now "limit_req" directive conforms to the leaky bucket
algorithm.
Thanks to Maxim Dounin.
*) Bugfix: in ngx_http_limit_req_module.
Thanks to Maxim Dounin.
*) Bugfix: now nginx allows underscores in a request method.
*) Bugfix: "proxy_pass_header" and "fastcgi_pass_header" directives did
not pass to a client the "X-Accel-Redirect", "X-Accel-Limit-Rate",
"X-Accel-Buffering", and "X-Accel-Charset" lines from backend
response header.
Thanks to Maxim Dounin.
*) Bugfix: in handling "Last-Modified" and "Accept-Ranges" backend
response header lines; the bug had appeared in 0.7.44.
Thanks to Maxim Dounin.
*) Feature: the "image_filter_transparency" directive.
*) Feature: the "image_filter" directive supports variables for setting
size.
*) Bugfix: in PNG alpha-channel support in the
ngx_http_image_filter_module.
*) Bugfix: in transparency support in the ngx_http_image_filter_module.
*) Feature: now several "perl_modules" directives may be used.
*) Bugfix: ngx_http_perl_module responses did not work in subrequests.
*) Bugfix: nginx sent '\0' in a "Location" response header line on
MKCOL request.
Thanks to Xie Zhenye.
*) Bugfix: an "error_page" directive did not redirect a 413 error; the
bug had appeared in 0.6.10.
*) Bugfix: in memory allocation error handling.
Thanks to Maxim Dounin and Kirill A. Korinskiy.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 26 Oct 2009 00:00:00 +0300 |
parents | 549994537f15 |
children | b9fdcaf2062b |
line wrap: on
line diff
--- a/src/http/modules/perl/ngx_http_perl_module.c +++ b/src/http/modules/perl/ngx_http_perl_module.c @@ -13,8 +13,8 @@ typedef struct { PerlInterpreter *perl; HV *nginx; - ngx_str_t modules; - ngx_array_t requires; + ngx_array_t *modules; + ngx_array_t *requires; } ngx_http_perl_main_conf_t; @@ -57,8 +57,6 @@ static char *ngx_http_perl_init_main_con static void *ngx_http_perl_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_perl_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); -static char *ngx_http_perl_require(ngx_conf_t *cf, ngx_command_t *cmd, - void *conf); static char *ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -74,16 +72,16 @@ static ngx_command_t ngx_http_perl_comm { ngx_string("perl_modules"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, - ngx_conf_set_str_slot, + ngx_conf_set_str_array_slot, NGX_HTTP_MAIN_CONF_OFFSET, offsetof(ngx_http_perl_main_conf_t, modules), NULL }, { ngx_string("perl_require"), NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, - ngx_http_perl_require, + ngx_conf_set_str_array_slot, NGX_HTTP_MAIN_CONF_OFFSET, - 0, + offsetof(ngx_http_perl_main_conf_t, requires), NULL }, { ngx_string("perl"), @@ -458,8 +456,10 @@ ngx_http_perl_ssi(ngx_http_request_t *r, static char * ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf) { + ngx_str_t *m; + ngx_uint_t i; #if (NGX_HAVE_PERL_MULTIPLICITY) - ngx_pool_cleanup_t *cln; + ngx_pool_cleanup_t *cln; cln = ngx_pool_cleanup_add(cf->pool, 0); if (cln == NULL) { @@ -471,14 +471,29 @@ ngx_http_perl_init_interpreter(ngx_conf_ #endif #ifdef NGX_PERL_MODULES - if (pmcf->modules.data == NULL) { - pmcf->modules.data = NGX_PERL_MODULES; + if (pmcf->modules == NGX_CONF_UNSET_PTR) { + + pmcf->modules = ngx_array_create(cf->pool, 1, sizeof(ngx_str_t)); + if (pmcf->modules == NULL) { + return NGX_CONF_ERROR; + } + + m = ngx_array_push(pmcf->modules); + if (m == NULL) { + return NGX_CONF_ERROR; + } + + m->len = sizeof(NGX_PERL_MODULES) - 1; + m->data = NGX_PERL_MODULES; } #endif - if (pmcf->modules.data) { - if (ngx_conf_full_name(cf->cycle, &pmcf->modules, 0) != NGX_OK) { - return NGX_CONF_ERROR; + if (pmcf->modules != NGX_CONF_UNSET_PTR) { + m = pmcf->modules->elts; + for (i = 0; i < pmcf->modules->nelts; i++) { + if (ngx_conf_full_name(cf->cycle, &m[i], 0) != NGX_OK) { + return NGX_CONF_ERROR; + } } } @@ -490,7 +505,7 @@ ngx_http_perl_init_interpreter(ngx_conf_ return NGX_CONF_ERROR; } - if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, cf->log) + if (ngx_http_perl_run_requires(aTHX_ pmcf->requires, cf->log) != NGX_OK) { return NGX_CONF_ERROR; @@ -538,7 +553,9 @@ ngx_http_perl_create_interpreter(ngx_con int n; STRLEN len; SV *sv; - char *ver, *embedding[6]; + char *ver, **embedding; + ngx_str_t *m; + ngx_uint_t i; PerlInterpreter *perl; ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, "create perl interpreter"); @@ -564,15 +581,21 @@ ngx_http_perl_create_interpreter(ngx_con PL_exit_flags |= PERL_EXIT_DESTRUCT_END; #endif + n = (pmcf->modules != NGX_CONF_UNSET_PTR) ? pmcf->modules->nelts * 2 : 0; + + embedding = ngx_palloc(cf->pool, (4 + n) * sizeof(char *)); + if (embedding == NULL) { + goto fail; + } + embedding[0] = ""; - if (pmcf->modules.data) { - embedding[1] = "-I"; - embedding[2] = (char *) pmcf->modules.data; - n = 3; - - } else { - n = 1; + if (n++) { + m = pmcf->modules->elts; + for (i = 0; i < pmcf->modules->nelts; i++) { + embedding[2 * i + 1] = "-I"; + embedding[2 * i + 2] = (char *) m[i].data; + } } embedding[n++] = "-Mnginx"; @@ -596,7 +619,7 @@ ngx_http_perl_create_interpreter(ngx_con goto fail; } - if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, cf->log) != NGX_OK) { + if (ngx_http_perl_run_requires(aTHX_ pmcf->requires, cf->log) != NGX_OK) { goto fail; } @@ -617,26 +640,28 @@ fail: static ngx_int_t ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log) { - char **script; + u_char *err; STRLEN len; - ngx_str_t err; + ngx_str_t *script; ngx_uint_t i; + if (requires == NGX_CONF_UNSET_PTR) { + return NGX_OK; + } + script = requires->elts; for (i = 0; i < requires->nelts; i++) { - require_pv(script[i]); + require_pv((char *) script[i].data); if (SvTRUE(ERRSV)) { - err.data = (u_char *) SvPV(ERRSV, len); - for (len--; err.data[len] == LF || err.data[len] == CR; len--) { - /* void */ - } - err.len = len + 1; + err = (u_char *) SvPV(ERRSV, len); + while (--len && (err[len] == CR || err[len] == LF)) { /* void */ } ngx_log_error(NGX_LOG_EMERG, log, 0, - "require_pv(\"%s\") failed: \"%V\"", script[i], &err); + "require_pv(\"%s\") failed: \"%*s\"", + script[i].data, len + 1, err); return NGX_ERROR; } @@ -653,8 +678,8 @@ ngx_http_perl_call_handler(pTHX_ ngx_htt SV *sv; int n, status; char *line; + u_char *err; STRLEN len, n_a; - ngx_str_t err; ngx_uint_t i; ngx_connection_t *c; @@ -724,14 +749,11 @@ ngx_http_perl_call_handler(pTHX_ ngx_htt if (SvTRUE(ERRSV)) { - err.data = (u_char *) SvPV(ERRSV, len); - for (len--; err.data[len] == LF || err.data[len] == CR; len--) { - /* void */ - } - err.len = len + 1; + err = (u_char *) SvPV(ERRSV, len); + while (--len && (err[len] == CR || err[len] == LF)) { /* void */ } ngx_log_error(NGX_LOG_ERR, c->log, 0, - "call_sv(\"%V\") failed: \"%V\"", handler, &err); + "call_sv(\"%V\") failed: \"%*s\"", handler, len + 1, err); if (rv) { return NGX_ERROR; @@ -765,7 +787,10 @@ ngx_http_perl_eval_anon_sub(pTHX_ ngx_st } } - if (ngx_strncmp(p, "sub ", 4) == 0 || ngx_strncmp(p, "use ", 4) == 0) { + if (ngx_strncmp(p, "sub ", 4) == 0 + || ngx_strncmp(p, "sub{", 4) == 0 + || ngx_strncmp(p, "use ", 4) == 0) + { *sv = eval_pv((char *) p, FALSE); /* eval_pv() does not set ERRSV on failure */ @@ -784,14 +809,11 @@ ngx_http_perl_create_main_conf(ngx_conf_ pmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_main_conf_t)); if (pmcf == NULL) { - return NGX_CONF_ERROR; + return NULL; } - if (ngx_array_init(&pmcf->requires, cf->pool, 1, sizeof(u_char *)) - != NGX_OK) - { - return NULL; - } + pmcf->modules = NGX_CONF_UNSET_PTR; + pmcf->requires = NGX_CONF_UNSET_PTR; return pmcf; } @@ -869,7 +891,7 @@ ngx_http_perl_create_loc_conf(ngx_conf_t plcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_loc_conf_t)); if (plcf == NULL) { - return NGX_CONF_ERROR; + return NULL; } /* @@ -898,28 +920,6 @@ ngx_http_perl_merge_loc_conf(ngx_conf_t static char * -ngx_http_perl_require(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) -{ - ngx_http_perl_main_conf_t *pmcf = conf; - - u_char **p; - ngx_str_t *value; - - value = cf->args->elts; - - p = ngx_array_push(&pmcf->requires); - - if (p == NULL) { - return NGX_CONF_ERROR; - } - - *p = value[1].data; - - return NGX_CONF_OK; -} - - -static char * ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_perl_loc_conf_t *plcf = conf;