summaryrefslogtreecommitdiff
path: root/sapi/apache2handler/sapi_apache2.c
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2005-07-25 22:38:11 +0000
committerRasmus Lerdorf <rasmus@php.net>2005-07-25 22:38:11 +0000
commit884c97d4d7000422475c424125032d8d15fa0933 (patch)
tree899c771dfef2430204956e064cdcefa5570141c9 /sapi/apache2handler/sapi_apache2.c
parentc35454440cb2a150129dd90a8383924044d343fa (diff)
downloadphp-git-884c97d4d7000422475c424125032d8d15fa0933.tar.gz
MFB fix for bug #33690
Diffstat (limited to 'sapi/apache2handler/sapi_apache2.c')
-rw-r--r--sapi/apache2handler/sapi_apache2.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c
index 72b181371b..ba50b67ac3 100644
--- a/sapi/apache2handler/sapi_apache2.c
+++ b/sapi/apache2handler/sapi_apache2.c
@@ -454,6 +454,21 @@ static int php_handler(request_rec *r)
TSRMLS_FETCH();
conf = ap_get_module_config(r->per_dir_config, &php5_module);
+
+ /* apply_config() needs r in some cases, so allocate server_context early */
+ ctx = SG(server_context);
+ if (ctx == NULL) {
+ ctx = SG(server_context) = apr_pcalloc(r->pool, sizeof(*ctx));
+ /* register a cleanup so we clear out the SG(server_context)
+ * after each request. Note: We pass in the pointer to the
+ * server_context in case this is handled by a different thread.
+ */
+ apr_pool_cleanup_register(r->pool, (void *)&SG(server_context), php_server_context_cleanup, apr_pool_cleanup_null);
+ ctx->r = r;
+ ctx = NULL; /* May look weird to null it here, but it is to catch the right case in the first_try later on */
+ } else {
+ ctx->r = r;
+ }
apply_config(conf);
if (strcmp(r->handler, PHP_MAGIC_TYPE) && strcmp(r->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(r->handler, PHP_SCRIPT)) {
@@ -511,17 +526,9 @@ static int php_handler(request_rec *r)
zend_first_try {
- ctx = SG(server_context);
if (ctx == NULL) {
- ctx = SG(server_context) = apr_pcalloc(r->pool, sizeof(*ctx));
- /* register a cleanup so we clear out the SG(server_context)
- * after each request. Note: We pass in the pointer to the
- * server_context in case this is handled by a different thread.
- */
- apr_pool_cleanup_register(r->pool, (void *)&SG(server_context), php_server_context_cleanup, apr_pool_cleanup_null);
-
- ctx->r = r;
brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc);
+ ctx = SG(server_context);
ctx->brigade = brigade;
if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) {