comparison src/http/modules/perl/ngx_http_perl_module.c @ 870:783c198b4ded

fix recursive perl_set variable call
author Igor Sysoev <igor@sysoev.ru>
date Sat, 25 Nov 2006 23:27:06 +0000
parents 6a99bc84c135
children a980f66c04fb
comparison
equal deleted inserted replaced
869:978a1e0fa9c1 870:783c198b4ded
298 uintptr_t data) 298 uintptr_t data)
299 { 299 {
300 ngx_http_perl_variable_t *pv = (ngx_http_perl_variable_t *) data; 300 ngx_http_perl_variable_t *pv = (ngx_http_perl_variable_t *) data;
301 301
302 ngx_int_t rc; 302 ngx_int_t rc;
303 ngx_uint_t recursive;
303 ngx_str_t value; 304 ngx_str_t value;
304 ngx_http_perl_ctx_t *ctx; 305 ngx_http_perl_ctx_t *ctx;
305 ngx_http_perl_main_conf_t *pmcf; 306 ngx_http_perl_main_conf_t *pmcf;
306 307
307 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 308 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
314 if (ctx == NULL) { 315 if (ctx == NULL) {
315 return NGX_ERROR; 316 return NGX_ERROR;
316 } 317 }
317 318
318 ngx_http_set_ctx(r, ctx, ngx_http_perl_module); 319 ngx_http_set_ctx(r, ctx, ngx_http_perl_module);
319 } 320
320 321 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module);
321 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module); 322
322 323 rc = ngx_http_perl_get_interpreter(pmcf, &ctx->perl,
323 rc = ngx_http_perl_get_interpreter(pmcf, &ctx->perl, r->connection->log); 324 r->connection->log);
324 325
325 if (rc != NGX_OK) { 326 if (rc != NGX_OK) {
326 return rc; 327 return rc;
328 }
329
330 recursive = 0;
331
332 } else {
333 pmcf = NULL;
334 recursive = 1;
327 } 335 }
328 336
329 value.data = NULL; 337 value.data = NULL;
330 338
331 { 339 {
335 rc = ngx_http_perl_call_handler(aTHX_ r, pv->sub, NULL, 343 rc = ngx_http_perl_call_handler(aTHX_ r, pv->sub, NULL,
336 &pv->handler, &value); 344 &pv->handler, &value);
337 345
338 } 346 }
339 347
340 ngx_http_perl_free_interpreter(pmcf, ctx->perl); 348 if (recursive == 0) {
349 ngx_http_perl_free_interpreter(pmcf, ctx->perl);
350 }
341 351
342 if (value.data) { 352 if (value.data) {
343 v->len = value.len; 353 v->len = value.len;
344 v->valid = 1; 354 v->valid = 1;
345 v->no_cachable = 0; 355 v->no_cachable = 0;