summaryrefslogtreecommitdiff
blob: 49f5c95461969b0d304817cec22c85a1d11f1c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- sapi/apache2handler/sapi_apache2.c	2005-10-12 23:41:36.000000000 +0200
+++ sapi/apache2handler/sapi_apache2.c	2005-11-18 21:19:33.000000000 +0100
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sapi_apache2.c,v 1.1.2.40.2.5 2005/10/12 21:41:36 tony2001 Exp $ */
+/* $Id: sapi_apache2.c,v 1.1.2.40.2.8 2005/11/18 19:03:13 iliaa Exp $ */
 
 #include <fcntl.h>
 
@@ -443,6 +443,18 @@
 	php_request_shutdown(NULL);
 }
 
+static void php_apache_ini_dtor(request_rec *r, request_rec *p TSRMLS_DC)
+{
+	if (strcmp(r->protocol, "INCLUDED")) {
+		zend_try { zend_ini_deactivate(TSRMLS_C); } zend_end_try();
+	}
+	if (p) {
+		((php_struct *)SG(server_context))->r = p;
+	} else {
+		apr_pool_cleanup_run(r->pool, (void *)&SG(server_context), php_server_context_cleanup);
+	}
+}
+
 static int php_handler(request_rec *r)
 {
 	php_struct *ctx;
@@ -453,10 +465,7 @@
 	request_rec *parent_req = NULL;
 	TSRMLS_FETCH();
 
-#define PHPAP_INI_OFF \
-	if (strcmp(r->protocol, "INCLUDED")) { \
-		zend_try { zend_ini_deactivate(TSRMLS_C); } zend_end_try(); \
-	} \
+#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req TSRMLS_CC);
 
 	conf = ap_get_module_config(r->per_dir_config, &php4_module);
 
@@ -535,7 +544,7 @@
 		if (!parent_req) {
 			parent_req = ctx->r;
 		}
-		if (parent_req && strcmp(parent_req->handler, PHP_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SCRIPT)) {
+		if (parent_req && parent_req->handler && strcmp(parent_req->handler, PHP_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SCRIPT)) {
 			if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) {
 				zend_bailout();
 			}