Mercurial > hg > nginx-quic
comparison src/http/modules/perl/nginx.xs @ 7527:02cd116ebe2a
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 12 Jul 2019 15:34:37 +0300 |
parents | 8125552a10ca |
children | 0cb693b4cbbb |
comparison
equal
deleted
inserted
replaced
7526:8125552a10ca | 7527:02cd116ebe2a |
---|---|
398 ngx_http_perl_ctx_t *ctx; | 398 ngx_http_perl_ctx_t *ctx; |
399 ngx_int_t rc; | 399 ngx_int_t rc; |
400 | 400 |
401 ngx_http_perl_set_request(r, ctx); | 401 ngx_http_perl_set_request(r, ctx); |
402 | 402 |
403 if (ctx->next) { | |
404 croak("has_request_body(): another handler active"); | |
405 } | |
406 | |
403 if (r->headers_in.content_length_n <= 0 && !r->headers_in.chunked) { | 407 if (r->headers_in.content_length_n <= 0 && !r->headers_in.chunked) { |
404 XSRETURN_UNDEF; | 408 XSRETURN_UNDEF; |
405 } | 409 } |
406 | 410 |
407 ctx->next = SvRV(ST(1)); | 411 ctx->next = SvRV(ST(1)); |
1091 ngx_http_perl_ctx_t *ctx; | 1095 ngx_http_perl_ctx_t *ctx; |
1092 ngx_msec_t sleep; | 1096 ngx_msec_t sleep; |
1093 | 1097 |
1094 ngx_http_perl_set_request(r, ctx); | 1098 ngx_http_perl_set_request(r, ctx); |
1095 | 1099 |
1100 if (ctx->next) { | |
1101 croak("sleep(): another handler active"); | |
1102 } | |
1103 | |
1096 sleep = (ngx_msec_t) SvIV(ST(1)); | 1104 sleep = (ngx_msec_t) SvIV(ST(1)); |
1097 | 1105 |
1098 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1106 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1099 "perl sleep: %M", sleep); | 1107 "perl sleep: %M", sleep); |
1100 | 1108 |