aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/perl/ngx_http_perl_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-09-28 16:07:14 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-09-28 16:07:14 +0000
commitd9ef969e28f5d2bd2f1a12c22ffa13043474e185 (patch)
tree950759e7f27985a9e85b2130613db86e6e3772c0 /src/http/modules/perl/ngx_http_perl_module.c
parent2c808cc191f9196117b60714ab7d1cdcbcd42c0c (diff)
downloadnginx-d9ef969e28f5d2bd2f1a12c22ffa13043474e185.tar.gz
nginx-d9ef969e28f5d2bd2f1a12c22ffa13043474e185.zip
use ngx_conf_set_str_array_slot() for perl_require
Diffstat (limited to 'src/http/modules/perl/ngx_http_perl_module.c')
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index 52084bae1..876eff46c 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -14,7 +14,7 @@ typedef struct {
PerlInterpreter *perl;
HV *nginx;
ngx_str_t modules;
- ngx_array_t requires;
+ ngx_array_t *requires;
} ngx_http_perl_main_conf_t;
@@ -57,8 +57,6 @@ static char *ngx_http_perl_init_main_conf(ngx_conf_t *cf, void *conf);
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);
@@ -81,9 +79,9 @@ static ngx_command_t ngx_http_perl_commands[] = {
{ 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"),
@@ -495,7 +493,7 @@ ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
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;
@@ -601,7 +599,7 @@ ngx_http_perl_create_interpreter(ngx_conf_t *cf,
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;
}
@@ -622,15 +620,19 @@ 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 *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)) {
@@ -639,7 +641,7 @@ ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
ngx_log_error(NGX_LOG_EMERG, log, 0,
"require_pv(\"%s\") failed: \"%*s\"",
- script[i], len + 1, err);
+ script[i].data, len + 1, err);
return NGX_ERROR;
}
@@ -781,11 +783,7 @@ ngx_http_perl_create_main_conf(ngx_conf_t *cf)
return NULL;
}
- if (ngx_array_init(&pmcf->requires, cf->pool, 1, sizeof(u_char *))
- != NGX_OK)
- {
- return NULL;
- }
+ pmcf->requires = NGX_CONF_UNSET_PTR;
return pmcf;
}
@@ -892,28 +890,6 @@ 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)
-{
- 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;