Welcome! Log In Create A New Profile

Advanced

[nginx] Perl: protection against duplicate $r->sleep() calls.

Maxim Dounin
July 12, 2019 10:56AM
details: https://hg.nginx.org/nginx/rev/02cd116ebe2a
branches:
changeset: 7527:02cd116ebe2a
user: Maxim Dounin <mdounin@mdounin.ru>
date: Fri Jul 12 15:34:37 2019 +0300
description:
Perl: protection against duplicate $r->sleep() calls.

Duplicate $r->sleep() and/or $r->has_request_body() calls result
in undefined behaviour (in practice, connection leaks were observed).
To prevent this, croak() added in appropriate places.

diffstat:

src/http/modules/perl/nginx.xs | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diffs (25 lines):

diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -400,6 +400,10 @@ has_request_body(r, next)

ngx_http_perl_set_request(r, ctx);

+ if (ctx->next) {
+ croak("has_request_body(): another handler active");
+ }
+
if (r->headers_in.content_length_n <= 0 && !r->headers_in.chunked) {
XSRETURN_UNDEF;
}
@@ -1093,6 +1097,10 @@ sleep(r, sleep, next)

ngx_http_perl_set_request(r, ctx);

+ if (ctx->next) {
+ croak("sleep(): another handler active");
+ }
+
sleep = (ngx_msec_t) SvIV(ST(1));

ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Perl: protection against duplicate $r->sleep() calls.

Maxim Dounin 248 July 12, 2019 10:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 291
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready