summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli.c
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2008-06-24 22:22:48 +0000
committerAndrey Hristov <andrey@php.net>2008-06-24 22:22:48 +0000
commit827b772c9fbfc52fb1fdabf96813eca6f319f961 (patch)
treeb9502d2937e9c50fff58b17c107efa031e0a667a /ext/mysqli/mysqli.c
parent4a58de4c5cc4452fb8fd37d547035cee31318d01 (diff)
downloadphp-git-827b772c9fbfc52fb1fdabf96813eca6f319f961.tar.gz
Fix remaining valgrind problems with pconn and zval cache
HEAD merge will follow tomorrow.
Diffstat (limited to 'ext/mysqli/mysqli.c')
-rw-r--r--ext/mysqli/mysqli.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index f8350be3fb..fda5a846a8 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -94,12 +94,8 @@ static int le_pmysqli;
/* Destructor for mysqli entries in free_links/used_links */
void php_mysqli_dtor_p_elements(void *data)
{
- MYSQL *mysql = (MYSQL *) data;
-#if defined(MYSQLI_USE_MYSQLND)
TSRMLS_FETCH();
-
- mysqlnd_end_psession(mysql);
-#endif
+ MYSQL *mysql = (MYSQL *) data;
mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT);
}
@@ -232,9 +228,6 @@ static void mysqli_link_free_storage(void *object TSRMLS_DC)
MY_MYSQL *mysql = (MY_MYSQL *)my_res->ptr;
if (mysql->mysql) {
if (!mysql->persistent) {
-#ifdef MYSQLI_USE_MYSQLND
- mysqlnd_end_psession(mysql->mysql);
-#endif
mysqli_close(mysql->mysql, MYSQLI_CLOSE_IMPLICIT);
} else {
zend_rsrc_list_entry *le;
@@ -959,6 +952,26 @@ PHP_RINIT_FUNCTION(mysqli)
}
/* }}} */
+
+#ifdef MYSQLI_USE_MYSQLND
+static void php_mysqli_persistent_helper_for_every(void *p)
+{
+ TSRMLS_FETCH();
+ mysqlnd_end_psession((MYSQLND *) p);
+} /* }}} */
+
+
+static int php_mysqli_persistent_helper_once(zend_rsrc_list_entry *le TSRMLS_DC)
+{
+ if (le->type == php_le_pmysqli()) {
+ mysqli_plist_entry *plist = (mysqli_plist_entry *) le->ptr;
+ zend_ptr_stack_apply(&plist->free_links, php_mysqli_persistent_helper_for_every);
+ }
+ return ZEND_HASH_APPLY_KEEP;
+} /* }}} */
+#endif
+
+
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(mysqli)
@@ -972,6 +985,7 @@ PHP_RSHUTDOWN_FUNCTION(mysqli)
efree(MyG(error_msg));
}
#ifdef MYSQLI_USE_MYSQLND
+ zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysqli_persistent_helper_once TSRMLS_CC);
mysqlnd_palloc_rshutdown(MyG(mysqlnd_thd_zval_cache));
#endif
return SUCCESS;