sixd Mon Mar 9 20:09:07 2009 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/oci8/tests b47243_1.phpt b47243_2.phpt b47243_3.phpt
Modified files:
/php-src/ext/oci8 oci8.c php_oci8_int.h
/php-src/ext/oci8/tests debug.phpt
Log:
MFH: Bug #47243 (Crash at shutdown on Windows)
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.269.2.16.2.38.2.30&r2=1.269.2.16.2.38.2.31&diff_format=u
Index: php-src/ext/oci8/oci8.c
diff -u php-src/ext/oci8/oci8.c:1.269.2.16.2.38.2.30
php-src/ext/oci8/oci8.c:1.269.2.16.2.38.2.31
--- php-src/ext/oci8/oci8.c:1.269.2.16.2.38.2.30 Mon Mar 9 19:01:16 2009
+++ php-src/ext/oci8/oci8.c Mon Mar 9 20:09:07 2009
@@ -26,7 +26,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8.c,v 1.269.2.16.2.38.2.30 2009/03/09 19:01:16 sixd Exp $ */
+/* $Id: oci8.c,v 1.269.2.16.2.38.2.31 2009/03/09 20:09:07 sixd Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -39,6 +39,14 @@
#if HAVE_OCI8
+#if PHP_MAJOR_VERSION > 5
+#error This version of the PHP OCI8 extension is not compatible with PHP 6 or
later
+#elif PHP_MAJOR_VERSION < 5
+#ifdef ZTS
+#error The PHP OCI8 extension does not support ZTS mode in PHP 4
+#endif
+#endif
+
#include "php_oci8.h"
#include "php_oci8_int.h"
#include "zend_hash.h"
@@ -47,6 +55,7 @@
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION >
5)
/* This "if" allows PECL builds from this file to be portable to older PHP
releases */
static PHP_GINIT_FUNCTION(oci);
+static PHP_GSHUTDOWN_FUNCTION(oci);
#endif
/* Allow PHP 5.3 branch to be used in PECL for 5.x compatible builds */
@@ -96,9 +105,6 @@
static void php_oci_collection_list_dtor (zend_rsrc_list_entry * TSRMLS_DC);
static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC);
-#ifdef ZTS
-static int php_oci_list_helper(zend_rsrc_list_entry *le, void *le_type
TSRMLS_DC);
-#endif
static int php_oci_connection_ping(php_oci_connection * TSRMLS_DC);
static int php_oci_connection_status(php_oci_connection * TSRMLS_DC);
static int php_oci_connection_close(php_oci_connection * TSRMLS_DC);
@@ -941,7 +947,7 @@
/* This check allows PECL builds from this file to be portable to older
PHP releases */
PHP_MODULE_GLOBALS(oci), /* globals descriptor */
PHP_GINIT(oci), /* globals ctor */
- NULL, /* globals dtor */
+ PHP_GSHUTDOWN(oci), /* globals dtor */
NULL, /* post deactivate */
STANDARD_MODULE_PROPERTIES_EX
#else
@@ -1068,6 +1074,21 @@
}
/* }}} */
+/* {{{ PHP_GSHUTDOWN_FUNCTION
+ *
+ * Called for thread shutdown in ZTS, after module shutdown for non-ZTS
+ */
+/* This check allows PECL builds from this file to be portable to older PHP
releases */
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION >
5)
+static PHP_GSHUTDOWN_FUNCTION(oci)
+#else
+static void php_oci_shutdown_globals(zend_oci_globals *oci_globals TSRMLS_DC)
+#endif
+{
+ php_oci_cleanup_global_handles(TSRMLS_C);
+}
+/* }}} */
+
PHP_MINIT_FUNCTION(oci)
{
zend_class_entry oci_lob_class_entry;
@@ -1077,7 +1098,7 @@
/* This check allows PECL builds from this file to be portable to older
PHP releases */
/* this is handled by new globals management code */
#else
- ZEND_INIT_MODULE_GLOBALS(oci, php_oci_init_globals, NULL);
+ ZEND_INIT_MODULE_GLOBALS(oci, php_oci_init_globals,
php_oci_shutdown_globals);
#endif
REGISTER_INI_ENTRIES();
@@ -1189,40 +1210,28 @@
PHP_MSHUTDOWN_FUNCTION(oci)
{
- OCI_G(shutdown) = 1;
-
- UNREGISTER_INI_ENTRIES();
-
+/* Work around PHP_GSHUTDOWN_FUNCTION not being called in older versions of
PHP */
+#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) || (PHP_MAJOR_VERSION <
5)
#ifndef ZTS
php_oci_cleanup_global_handles(TSRMLS_C);
#endif
+#endif
+
+ OCI_G(shutdown) = 1;
+
+ UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(oci)
{
-#ifdef ZTS
- zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t)
php_oci_list_helper, (void *)le_descriptor TSRMLS_CC);
- zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t)
php_oci_list_helper, (void *)le_collection TSRMLS_CC);
- while (OCI_G(num_statements) > 0) {
- zend_hash_apply_with_argument(&EG(regular_list),
(apply_func_arg_t) php_oci_list_helper, (void *)le_statement TSRMLS_CC);
- }
-#endif
-
/* Check persistent connections and do the necessary actions if needed.
If persistent_helper is
* unable to process a pconnection because of a refcount, the
processing would happen from
* np-destructor which is called when refcount goes to zero -
php_oci_pconnection_list_np_dtor
*/
zend_hash_apply(&EG(persistent_list), (apply_func_t)
php_oci_persistent_helper TSRMLS_CC);
-#ifdef ZTS
- while (OCI_G(num_links) > OCI_G(num_persistent)) {
- zend_hash_apply_with_argument(&EG(regular_list),
(apply_func_arg_t) php_oci_list_helper, (void *)le_connection TSRMLS_CC);
- }
- php_oci_cleanup_global_handles(TSRMLS_C);
-#endif
-
return SUCCESS;
}
@@ -1233,7 +1242,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "OCI8 Support", "enabled");
php_info_print_table_row(2, "Version", PHP_OCI8_VERSION);
- php_info_print_table_row(2, "Revision", "$Revision:
1.269.2.16.2.38.2.30 $");
+ php_info_print_table_row(2, "Revision", "$Revision:
1.269.2.16.2.38.2.31 $");
snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent));
php_info_print_table_row(2, "Active Persistent Connections", buf);
@@ -3105,24 +3114,6 @@
return OCI_SUCCESS;
} /* }}} */
-#ifdef ZTS
-/* {{{ php_oci_list_helper()
- *
- * Helper function to destroy data on thread shutdown in ZTS mode
- */
-static int php_oci_list_helper(zend_rsrc_list_entry *le, void *le_type
TSRMLS_DC)
-{
- int type = (int) le_type;
-
- if (le->type == type) {
- if (le->ptr != NULL && --le->refcount<=0) {
- return ZEND_HASH_APPLY_REMOVE;
- }
- }
- return ZEND_HASH_APPLY_KEEP;
-} /* }}} */
-#endif
-
#endif /* HAVE_OCI8 */
/*
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.11.2.6.2.21.2.12&r2=1.11.2.6.2.21.2.13&diff_format=u
Index: php-src/ext/oci8/php_oci8_int.h
diff -u php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.21.2.12
php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.21.2.13
--- php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.21.2.12 Wed Dec 31 11:15:39 2008
+++ php-src/ext/oci8/php_oci8_int.h Mon Mar 9 20:09:07 2009
@@ -25,7 +25,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_oci8_int.h,v 1.11.2.6.2.21.2.12 2008/12/31 11:15:39 sebastian Exp
$ */
+/* $Id: php_oci8_int.h,v 1.11.2.6.2.21.2.13 2009/03/09 20:09:07 sixd Exp $ */
#if HAVE_OCI8
# ifndef PHP_OCI8_INT_H
@@ -319,7 +319,7 @@
} while (0)
#define PHP_OCI_ZVAL_TO_CONNECTION(zval, connection) \
- ZEND_FETCH_RESOURCE2(connection, php_oci_connection *, &zval, -1, "oci8
connection", le_connection, le_pconnection);
+ ZEND_FETCH_RESOURCE2(connection, php_oci_connection *, &zval, -1, "oci8
connection", le_connection, le_pconnection)
#define PHP_OCI_ZVAL_TO_STATEMENT(zval, statement) \
ZEND_FETCH_RESOURCE(statement, php_oci_statement *, &zval, -1, "oci8
statement", le_statement)
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/debug.phpt?r1=1.1.2.4.4.3&r2=1.1.2.4.4.4&diff_format=u
Index: php-src/ext/oci8/tests/debug.phpt
diff -u php-src/ext/oci8/tests/debug.phpt:1.1.2.4.4.3
php-src/ext/oci8/tests/debug.phpt:1.1.2.4.4.4
--- php-src/ext/oci8/tests/debug.phpt:1.1.2.4.4.3 Thu Jun 19 19:56:11 2008
+++ php-src/ext/oci8/tests/debug.phpt Mon Mar 9 20:09:07 2009
@@ -59,3 +59,9 @@
OCI8 DEBUG: OCIHandleFree at (%s:%d)
OCI8 DEBUG: OCIHandleFree at (%s:%d)
Done
+OCI8 DEBUG: OCISessionPoolDestroy at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/b47243_1.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/b47243_1.phpt
+++ php-src/ext/oci8/tests/b47243_1.phpt
--TEST--
Bug #47243 (Crash on exit with ZTS mode)
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php
require(dirname(__FILE__).'/connect.inc');
// Run Test
$s = oci_parse($c, "select cursor(select dummy from dual) from dual");
oci_execute($s);
oci_fetch_all($s, $r);
// No explicit free or close
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/b47243_2.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/b47243_2.phpt
+++ php-src/ext/oci8/tests/b47243_2.phpt
--TEST--
Bug #47243 (Crash on exit with ZTS mode)
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php
require(dirname(__FILE__).'/connect.inc');
// Run Test
$s = oci_parse($c, "select cursor(select dummy from dual) from dual");
oci_execute($s);
oci_fetch_all($s, $r);
oci_free_statement($s);
// no explicit close
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/b47243_3.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/b47243_3.phpt
+++ php-src/ext/oci8/tests/b47243_3.phpt
--TEST--
Bug #47243 (Crash on exit with ZTS mode)
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php
require(dirname(__FILE__).'/connect.inc');
// Run Test
$s = oci_parse($c, "select cursor(select dummy from dual) from dual");
oci_execute($s);
oci_fetch_all($s, $r);
// With explicit free and close
oci_free_statement($s);
oci_close($c);
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php