mirror of
https://github.com/nginx/nginx.git
synced 2025-07-30 01:46:14 +08:00
optimize error handling
This commit is contained in:
parent
0056d6b4aa
commit
2c808cc191
@ -623,8 +623,8 @@ static ngx_int_t
|
|||||||
ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
|
ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
|
||||||
{
|
{
|
||||||
char **script;
|
char **script;
|
||||||
|
u_char *err;
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
ngx_str_t err;
|
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
|
|
||||||
script = requires->elts;
|
script = requires->elts;
|
||||||
@ -634,14 +634,12 @@ ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
|
|||||||
|
|
||||||
if (SvTRUE(ERRSV)) {
|
if (SvTRUE(ERRSV)) {
|
||||||
|
|
||||||
err.data = (u_char *) SvPV(ERRSV, len);
|
err = (u_char *) SvPV(ERRSV, len);
|
||||||
for (len--; err.data[len] == LF || err.data[len] == CR; len--) {
|
while (--len && (err[len] == CR || err[len] == LF)) { /* void */ }
|
||||||
/* void */
|
|
||||||
}
|
|
||||||
err.len = len + 1;
|
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_EMERG, log, 0,
|
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;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -658,8 +656,8 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, HV *nginx, SV *sub,
|
|||||||
SV *sv;
|
SV *sv;
|
||||||
int n, status;
|
int n, status;
|
||||||
char *line;
|
char *line;
|
||||||
|
u_char *err;
|
||||||
STRLEN len, n_a;
|
STRLEN len, n_a;
|
||||||
ngx_str_t err;
|
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_connection_t *c;
|
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)) {
|
if (SvTRUE(ERRSV)) {
|
||||||
|
|
||||||
err.data = (u_char *) SvPV(ERRSV, len);
|
err = (u_char *) SvPV(ERRSV, len);
|
||||||
for (len--; err.data[len] == LF || err.data[len] == CR; len--) {
|
while (--len && (err[len] == CR || err[len] == LF)) { /* void */ }
|
||||||
/* void */
|
|
||||||
}
|
|
||||||
err.len = len + 1;
|
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_ERR, c->log, 0,
|
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) {
|
if (rv) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
|
Loading…
Reference in New Issue
Block a user