Created
May 22, 2023 16:40
-
-
Save rlerdorf/04cc9f2ecb88baa226e00bd612fb63b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c | |
index e7d29450ee..066d2abbc9 100644 | |
--- a/sapi/apache2handler/php_functions.c | |
+++ b/sapi/apache2handler/php_functions.c | |
@@ -358,6 +358,26 @@ PHP_FUNCTION(apache_get_modules) | |
} | |
/* }}} */ | |
+PHP_FUNCTION(apache_finish_request) | |
+{ | |
+ php_struct *ctx; | |
+ apr_bucket *bucket; | |
+ apr_status_t rv; | |
+ | |
+ ctx = SG(server_context); | |
+ apr_brigade_cleanup(ctx->brigade); | |
+ bucket = apr_bucket_eos_create(ctx->r->connection->bucket_alloc); | |
+ APR_BRIGADE_INSERT_TAIL(ctx->brigade, bucket); | |
+ rv = ap_pass_brigade(ctx->r->output_filters, brigade); | |
+ if (rv != APR_SUCCESS || ctx->r->connection->aborted) { | |
+ zend_first_try { | |
+ php_handle_aborted_connection(); | |
+ } zend_end_try(); | |
+ } | |
+ apr_brigade_cleanup(ctx->brigade); | |
+ ctx->request_processed = 1; | |
+} | |
+ | |
PHP_MINFO_FUNCTION(apache) | |
{ | |
char *apv = php_apache_get_version(); | |
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c | |
index 2266b46e58..62a3849800 100644 | |
--- a/sapi/apache2handler/sapi_apache2.c | |
+++ b/sapi/apache2handler/sapi_apache2.c | |
@@ -714,18 +714,20 @@ zend_first_try { | |
if (!parent_req) { | |
php_apache_request_dtor(r); | |
- ctx->request_processed = 1; | |
- apr_brigade_cleanup(brigade); | |
- bucket = apr_bucket_eos_create(r->connection->bucket_alloc); | |
- APR_BRIGADE_INSERT_TAIL(brigade, bucket); | |
- | |
- rv = ap_pass_brigade(r->output_filters, brigade); | |
- if (rv != APR_SUCCESS || r->connection->aborted) { | |
+ if (!ctx->request_processed == 1) { | |
+ ctx->request_processed = 1; | |
+ apr_brigade_cleanup(brigade); | |
+ bucket = apr_bucket_eos_create(r->connection->bucket_alloc); | |
+ APR_BRIGADE_INSERT_TAIL(brigade, bucket); | |
+ | |
+ rv = ap_pass_brigade(r->output_filters, brigade); | |
+ if (rv != APR_SUCCESS || r->connection->aborted) { | |
zend_first_try { | |
- php_handle_aborted_connection(); | |
+ php_handle_aborted_connection(); | |
} zend_end_try(); | |
+ } | |
+ apr_brigade_cleanup(brigade); | |
} | |
- apr_brigade_cleanup(brigade); | |
apr_pool_cleanup_run(r->pool, (void *)&SG(server_context), php_server_context_cleanup); | |
} else { | |
ctx->r = parent_req; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related php/php-src#11250