Mercurial > hg > nginx
comparison src/http/modules/perl/ngx_http_perl_module.c @ 7525:575480d3fd01
Perl: propagate errors.
When an error happens, the ctx->error bit is now set, and croak()
is called to terminate further processing. The ctx->error bit is
checked in ngx_http_perl_call_handler() to cancel further processing,
and is also checked in various output functions - to make sure these won't
be called if croak() was handled by an eval{} in perl code.
In particular, this ensures that output chain won't be called after
errors, as filters might not expect this to happen. This fixes some
segmentation faults under low memory conditions. Also this stops
request processing after filter finalization or request body reading
errors.
For cases where an HTTP error status can be additionally returned (for
example, 416 (Requested Range Not Satisfiable) from the range filter),
the ctx->status field is also added.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 12 Jul 2019 13:56:21 +0300 |
parents | deebe988cbd7 |
children | 0cb693b4cbbb |
comparison
equal
deleted
inserted
replaced
7524:deebe988cbd7 | 7525:575480d3fd01 |
---|---|
244 } | 244 } |
245 | 245 |
246 ctx->filename.data = NULL; | 246 ctx->filename.data = NULL; |
247 ctx->redirect_uri.len = 0; | 247 ctx->redirect_uri.len = 0; |
248 | 248 |
249 if (rc == NGX_ERROR) { | |
250 ngx_http_finalize_request(r, rc); | |
251 return; | |
252 } | |
253 | |
249 if (ctx->done || ctx->next) { | 254 if (ctx->done || ctx->next) { |
250 ngx_http_finalize_request(r, NGX_DONE); | 255 ngx_http_finalize_request(r, NGX_DONE); |
251 return; | 256 return; |
252 } | 257 } |
253 | 258 |
688 | 693 |
689 dSP; | 694 dSP; |
690 | 695 |
691 status = 0; | 696 status = 0; |
692 | 697 |
698 ctx->error = 0; | |
699 ctx->status = NGX_OK; | |
700 | |
693 ENTER; | 701 ENTER; |
694 SAVETMPS; | 702 SAVETMPS; |
695 | 703 |
696 PUSHMARK(sp); | 704 PUSHMARK(sp); |
697 | 705 |
736 | 744 |
737 PUTBACK; | 745 PUTBACK; |
738 | 746 |
739 FREETMPS; | 747 FREETMPS; |
740 LEAVE; | 748 LEAVE; |
749 | |
750 if (ctx->error) { | |
751 | |
752 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
753 "call_sv: error, %d", ctx->status); | |
754 | |
755 if (ctx->status != NGX_OK) { | |
756 return ctx->status; | |
757 } | |
758 | |
759 return NGX_ERROR; | |
760 } | |
741 | 761 |
742 /* check $@ */ | 762 /* check $@ */ |
743 | 763 |
744 if (SvTRUE(ERRSV)) { | 764 if (SvTRUE(ERRSV)) { |
745 | 765 |