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 15:57:28 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-09-28 15:57:28 +0000
commit2c808cc191f9196117b60714ab7d1cdcbcd42c0c (patch)
treef000edca1c617db26bfd081740da6d644a3e2366 /src/http/modules/perl/ngx_http_perl_module.c
parent0056d6b4aa49668cc2aa8e2ad5ca17689165131b (diff)
downloadnginx-2c808cc191f9196117b60714ab7d1cdcbcd42c0c.tar.gz
nginx-2c808cc191f9196117b60714ab7d1cdcbcd42c0c.zip
optimize error handling
Diffstat (limited to 'src/http/modules/perl/ngx_http_perl_module.c')
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index 41372ce2d..52084bae1 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -623,8 +623,8 @@ 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_uint_t i;
script = requires->elts;
@@ -634,14 +634,12 @@ ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
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], len + 1, err);
return NGX_ERROR;
}
@@ -658,8 +656,8 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, HV *nginx, SV *sub,
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;
@@ -720,14 +718,11 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, HV *nginx, SV *sub,
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;