aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/perl/ngx_http_perl_module.c
Commit message (Collapse)AuthorAge
* Perl: named locations in $r->internal_redirect().Maxim Dounin2019-07-12
|
* Perl: expect escaped URIs in $r->internal_redirect().Maxim Dounin2019-07-12
| | | | | | Similarly to the change in 5491:74bfa803a5aa (1.5.9), we should accept properly escaped URIs and unescape them as needed, else it is not possible to handle URIs with question marks.
* Perl: additional ctx->header_sent checks.Maxim Dounin2019-07-12
| | | | | | | | | As we now have ctx->header_sent flag, it is further used to prevent duplicate $r->send_http_header() calls, prevent output before sending header, and $r->internal_redirect() after sending header. Further, $r->send_http_header() protected from calls after $r->internal_redirect().
* Perl: avoid returning 500 if header was already sent.Maxim Dounin2019-07-12
| | | | | | | Returning NGX_HTTP_INTERNAL_SERVER_ERROR if a perl code died after sending header will lead to a "header already sent" alert. To avoid it, we now check if header was already sent, and return NGX_ERROR instead if it was.
* Perl: avoid redirects on errors.Maxim Dounin2019-07-12
| | | | | | Previously, redirects scheduled with $r->internal_redirect() were followed even if the code then died. Now these are ignored and nginx will return an error instead.
* Perl: disabled unrelated calls from variable handlers.Maxim Dounin2019-07-12
| | | | | | Variable handlers are not expected to send anything to the client, cannot sleep or read body, and are not expected to modify the request. Added appropriate protection to prevent accidental foot shooting.
* Perl: propagate errors.Maxim Dounin2019-07-12
| | | | | | | | | | | | | | | | | | 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.
* Perl: reworked perl module to pass ctx instead of request.Maxim Dounin2019-07-12
| | | | | | | | | | | | | | | | | | | | | | This ensures that correct ctx is always available, including after filter finalization. In particular, this fixes a segmentation fault with the following configuration: location / { image_filter test; perl 'sub { my $r = shift; $r->send_http_header(); $r->print("foo\n"); $r->print("bar\n"); }'; } This also seems to be the only way to correctly handle filter finalization in various complex cases, for example, when embedded perl is used both in the original handler and in an error page called after filter finalization.
* Perl: removed unneeded NGX_DONE test.Maxim Dounin2019-07-11
| | | | | | | The NGX_DONE test in ngx_http_perl_handle_request() was introduced in 1702:86bb52e28ce0, which also modified ngx_http_perl_call_handler() to return NGX_DONE with c->destroyed. The latter part was then removed in 3050:f54b02dbb12b, so NGX_DONE test is no longer needed.
* Moved handling of wev->delayed to the connection event handler.Maxim Dounin2017-04-02
| | | | | | | | | | | With post_action or subrequests, it is possible that the timer set for wev->delayed will expire while the active subrequest write event handler is not ready to handle this. This results in request hangs as observed with limit_rate / sendfile_max_chunk and post_action (ticket #776) or subrequests (ticket #1228). Moving the handling to the connection event handler fixes the hangs observed, and also slightly simplifies the code.
* Perl: fixed delaying subrequests.Maxim Dounin2017-04-02
| | | | | Much like in limit_req, use the wev->delayed flag to ensure proper handling and interoperability with limit_rate.
* Perl: added PERL_SET_INTERP().Maxim Dounin2016-12-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For Perl compiled with threads, without PERL_SET_INTERP() the PL_curinterp remains set to the first interpreter created (that is, one created at original start). As a result after a reload Perl thinks that operations are done withing a thread, and, most notably, denies to change environment. For example, the following code properly works on original start, but fails after a reload: perl 'sub { my $r = shift; $r->send_http_header("text/plain"); $ENV{TZ} = "UTC"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); $ENV{TZ} = "Europe/Moscow"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); return OK; }'; To fix this, PERL_SET_INTERP() added anywhere where PERL_SET_CONTEXT() was previously used. Note that PERL_SET_INTERP() doesn't seem to be documented anywhere. Yet it is used in some other software, and also seems to be the only solution possible.
* Perl: fixed optimization in SSI command handler.Maxim Dounin2016-11-01
| | | | | | | | As the pointer to the first argument was tested instead of the argument itself, array of arguments was always created, even if there were no arguments. Fix is to test args[0] instead of args. Found by Coverity (CID 1356862).
* Perl: NULL-terminate argument list.Piotr Sikora2014-06-19
| | | | | | | | | | | perl_parse() function expects argv/argc-style argument list, which according to the C standard must be NULL-terminated, that is: argv[argc] == NULL. This change fixes a crash (SIGSEGV) that could happen because of the buffer overrun during perl module initialization. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Handling of ngx_int_t != intptr_t case.Maxim Dounin2013-09-04
| | | | | | | | | Casts between pointers and integers produce warnings on size mismatch. To silence them, cast to (u)intptr_t should be used. Prevoiusly, casts to ngx_(u)int_t were used in some cases, and several ngx_int_t expressions had no casts. As of now it's mostly style as ngx_int_t is defined as intptr_t.
* Backed out f1a91825730a and 7094bd12c1ff.Maxim Dounin2013-08-20
| | | | | | | While ngx_get_full_name() might have a bit more descriptive arguments, the ngx_conf_full_name() is generally easier to use when parsing configuration and limits exposure of cycle->prefix / cycle->conf_prefix details.
* Replaced ngx_conf_full_name() with ngx_get_full_name().Valentin Bartenev2013-08-06
| | | | The ngx_get_full_name() function takes more readable arguments list.
* Added checks that disallow adding a variable with an empty name.Ruslan Ermilov2012-12-17
| | | | Added variable name syntax checks to "geo" and "map" directives.
* Fixed variable syntax checking in "set", "geo", "limit_conn_zone",Ruslan Ermilov2012-12-13
| | | | and "perl_set" directives.
* Copyright updated.Maxim Konovalov2012-01-18
|
* remove r->zero_in_uriIgor Sysoev2010-05-24
|
* ngx_str_set() and ngx_str_null()Igor Sysoev2010-05-14
|
* delete ngx_http_perl_cleanup_t unused since r909Igor Sysoev2010-02-12
|
* add comment from r2716 commit messageIgor Sysoev2009-11-17
|
* use global perl variable in perl_destruct()/perl_free()Igor Sysoev2009-11-17
| | | | for non-mulitiplicity perl
* allow several perl_modulesIgor Sysoev2009-09-30
|
* use ngx_conf_set_str_array_slot() for perl_requireIgor Sysoev2009-09-28
|
* optimize error handlingIgor Sysoev2009-09-28
|
* allow perl "sub{..."Igor Sysoev2009-09-15
|
* fix request counter handling in perl module for $r->internal_redirect()Igor Sysoev2009-09-08
| | | | and $r->has_request_body(), the bug was introduced in r3050
* fix request counter handling for perl handler, introduced in r3050Igor Sysoev2009-09-04
|
* axe r->connection->destroyed testingIgor Sysoev2009-08-26
|
* return NULL instead of NGX_CONF_ERROR on a create conf failureIgor Sysoev2009-06-02
|
* remove TODO commentsIgor Sysoev2009-04-18
|
* perl termination fixes:Igor Sysoev2009-04-16
| | | | | | | | | | *) master exit hook is run before global pool cleanup, so call PERL_SYS_TERM() after perl_destruct()/perl_free(). This fixes the message panic: MUTEX_LOCK (22) [op.c:352] on some threaded perl builds *) call perl_destruct()/perl_free() before PERL_SYS_TERM() for non-mulitiplicity perl
* fix segfault on exit if no http section is defined in confguraiton,Igor Sysoev2009-04-15
| | | | the bug has been introduced in r1947
* fix segfault if no http section is defined in confguraiton,Igor Sysoev2009-04-15
| | | | the bug has been introduced in r1259
* use "!= NGX_OK" instead of "== NGX_ERROR"Igor Sysoev2008-12-09
|
* *) back out r2040Igor Sysoev2008-06-17
| | | | | | *) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
* some perl builds require my_perl for PERL_SYS_TERM()Igor Sysoev2008-03-17
|
* style fixIgor Sysoev2008-03-14
|
* fix building on 64-bit platforms broken in r1900Igor Sysoev2008-03-13
|
* pass additional arguments in ngx_http_perl_call_handler() as SVIgor Sysoev2008-02-16
|
* optimize $r->sleepIgor Sysoev2008-02-16
|
* fix segfault when $r->has_request_body() is called with ready bodyIgor Sysoev2007-12-09
|
* fix English grammarIgor Sysoev2007-10-14
|
* --sysconfdir=DIRIgor Sysoev2007-07-29
|
* fix building on threaded or multiplicity interpreter perl,Igor Sysoev2007-06-16
| | | | the bug was introduced by previous commit
* set worker's perl $$Igor Sysoev2007-06-15
|
* PERL_SYS_TERM() should be called once on exit only, this fixes the messageIgor Sysoev2007-05-29
| | | | | | | | | | | panic: MUTEX_LOCK (22) [op.c:352]. BEGIN failed--compilation aborted. ... [alert] ... perl_parse() failed: 9 Scalars leaked: 2 on threaded perl during second reconfiguration. PERL_SYS_INIT() should be called once too.