summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--ext/mysql/php_mysql.c24
-rw-r--r--ext/mysqli/mysqli.c22
3 files changed, 48 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 477e7c7f61..c4eb1f82dd 100644
--- a/NEWS
+++ b/NEWS
@@ -76,6 +76,8 @@ PHP NEWS
- Fixed bug #41527 (WDDX deserialize numeric string array key). (Matt, Ilia)
- Fixed bug #41518 (file_exists() warns of open_basedir restriction on
non-existent file). (Tony)
+- Fixed bug #41350 (my_thread_global_end() error during request shutdown
+ on Windows). (Scott, Andrey)
- Fixed bug #39330 (apache2handler does not call shutdown actions before
apache child die). (isk at ecommerce dot com, Gopal, Tony)
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 35b9dc66c1..0e8f3caa4d 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -401,6 +401,10 @@ ZEND_MODULE_STARTUP_D(mysql)
REGISTER_LONG_CONSTANT("MYSQL_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQL_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT);
+ if (mysql_server_init(0, NULL, NULL)) {
+ return FAILURE;
+ }
+
return SUCCESS;
}
/* }}} */
@@ -409,6 +413,16 @@ ZEND_MODULE_STARTUP_D(mysql)
*/
PHP_MSHUTDOWN_FUNCTION(mysql)
{
+#ifdef PHP_WIN32
+ unsigned long client_ver = mysql_get_client_version;
+ /* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
+ if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+ mysql_server_end();
+ }
+#else
+ mysql_server_end();
+#endif
+
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
@@ -418,12 +432,18 @@ PHP_MSHUTDOWN_FUNCTION(mysql)
*/
PHP_RINIT_FUNCTION(mysql)
{
+#ifdef ZTS
+ if (mysql_thread_init()) {
+ return FAILURE;
+ }
+#endif
MySG(default_link)=-1;
MySG(num_links) = MySG(num_persistent);
/* Reset connect error/errno on every request */
MySG(connect_error) = NULL;
MySG(connect_errno) =0;
MySG(result_allocated) = 0;
+
return SUCCESS;
}
/* }}} */
@@ -432,6 +452,10 @@ PHP_RINIT_FUNCTION(mysql)
*/
PHP_RSHUTDOWN_FUNCTION(mysql)
{
+#ifdef ZTS
+ mysql_thread_end();
+#endif
+
if (MySG(trace_mode)) {
if (MySG(result_allocated)){
php_error_docref("function.mysql-free-result" TSRMLS_CC, E_WARNING, "%lu result set(s) not freed. Use mysql_free_result to free result sets which were requested using mysql_query()", MySG(result_allocated));
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index d9fe89c661..4f1d81307e 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -652,6 +652,10 @@ PHP_MINIT_FUNCTION(mysqli)
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ALL", MYSQLI_REPORT_ALL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MYSQLI_REPORT_OFF", 0, CONST_CS | CONST_PERSISTENT);
+ if (mysql_server_init(0, NULL, NULL)) {
+ return FAILURE;
+ }
+
return SUCCESS;
}
/* }}} */
@@ -660,6 +664,16 @@ PHP_MINIT_FUNCTION(mysqli)
*/
PHP_MSHUTDOWN_FUNCTION(mysqli)
{
+#ifdef PHP_WIN32
+ unsigned long client_ver = mysql_get_client_version;
+ /* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
+ if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+ mysql_server_end();
+ }
+#else
+ mysql_server_end();
+#endif
+
zend_hash_destroy(&mysqli_driver_properties);
zend_hash_destroy(&mysqli_result_properties);
zend_hash_destroy(&mysqli_stmt_properties);
@@ -676,6 +690,11 @@ PHP_MSHUTDOWN_FUNCTION(mysqli)
*/
PHP_RINIT_FUNCTION(mysqli)
{
+#ifdef ZTS
+ if (mysql_thread_init()) {
+ return FAILURE;
+ }
+#endif
MyG(error_msg) = NULL;
MyG(error_no) = 0;
@@ -687,6 +706,9 @@ PHP_RINIT_FUNCTION(mysqli)
*/
PHP_RSHUTDOWN_FUNCTION(mysqli)
{
+#ifdef ZTS
+ mysql_thread_end();
+#endif
if (MyG(error_msg)) {
efree(MyG(error_msg));
}