apache2handler sapi registers cleanup functions only for main apache process.
But apache 2 cleans _only_ child pool before it die.
This is reason for unclean connection closes in persistent connection (in pgsql 
exactly).

This patch adds shutdown actions registration on each child init.
Apache child will be call php_apache_server_shutdow() before it die like 
handler for Apache 1.3.
This patch closes bug #39330.
Index: sapi/apache2handler/sapi_apache2.c
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/sapi_apache2.c,v
retrieving revision 1.75
diff -u -r1.75 sapi_apache2.c
--- sapi/apache2handler/sapi_apache2.c	23 Oct 2006 19:17:51 -0000	1.75
+++ sapi/apache2handler/sapi_apache2.c	7 Nov 2006 07:26:44 -0000
@@ -414,6 +414,11 @@
 	return OK;
 }
 
+static void php_apache_child_init(apr_pool_t *pchild, server_rec *s)
+{
+	apr_pool_cleanup_register(pchild, NULL, php_apache_server_shutdown, apr_pool_cleanup_null);
+}
+
 static apr_status_t php_server_context_cleanup(void *data_)
 {
 	void **data = data_;
@@ -631,6 +636,7 @@
 {
 	ap_hook_pre_config(php_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
 	ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
+	ap_hook_child_init(php_apache_child_init, NULL, NULL, APR_HOOK_MIDDLE);
 	ap_hook_handler(php_handler, NULL, NULL, APR_HOOK_MIDDLE);
 }
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to