diff options
author | Valentin Bartenev <vbart@nginx.com> | 2020-11-11 12:09:49 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2020-11-11 12:09:49 +0300 |
commit | cb28b41311479424cdf3b217a2252518da34c23d (patch) | |
tree | 6bde24a4eb89d872f981e648ca0c7ff13bb7b66d /src | |
parent | 896d8e8bfb3d8649db467d92e06c789b789d3feb (diff) | |
download | unit-cb28b41311479424cdf3b217a2252518da34c23d.tar.gz unit-cb28b41311479424cdf3b217a2252518da34c23d.tar.bz2 |
PHP: prevention of consuming unread request body on finalization.
The php_request_shutdown() function calls sapi_deactivate() that tries to read
request body into a dummy buffer. In our case it's just waste of CPU cycles.
This change is also required for the following implementation of the
fastcgi_finish_request() function, where the request context can be
cleared by the time of finalization.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_php_sapi.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index 234ceef8..f6539af5 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -934,6 +934,9 @@ nxt_php_dynamic_request(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r) static void nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r) { +#if (PHP_VERSION_ID < 50600) + void *read_post; +#endif nxt_unit_field_t *f; zend_file_handle file_handle; @@ -990,9 +993,21 @@ nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r) php_execute_script(&file_handle TSRMLS_CC); + /* Prevention of consuming possible unread request body. */ +#if (PHP_VERSION_ID < 50600) + read_post = sapi_module.read_post; + sapi_module.read_post = NULL; +#else + SG(post_read) = 1; +#endif + php_request_shutdown(NULL); nxt_unit_request_done(ctx->req, NXT_UNIT_OK); + +#if (PHP_VERSION_ID < 50600) + sapi_module.read_post = read_post; +#endif } |