]> granicus.if.org Git - php/commitdiff
Fix for bug #51605 (Mysqli zombie links)
authorAndrey Hristov <andrey@php.net>
Tue, 11 May 2010 10:03:16 +0000 (10:03 +0000)
committerAndrey Hristov <andrey@php.net>
Tue, 11 May 2010 10:03:16 +0000 (10:03 +0000)
NEWS
ext/mysqli/mysqli_api.c
ext/mysqli/tests/bug51605.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7108bd2959158d1291c626a8ad0c6ef64ca07627..052dd8f06f73e02db5b7f75ee0c91993be90e20e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,7 @@ PHP                                                                        NEWS
   literal). (cbandy at jbandy dot com)
 - Fixed bug #51607 (pg_copy_from does not allow schema in the tablename
   argument). (cbandy at jbandy dot com)
+- Fixed bug #51605 (Mysqli - zombie links). (Andrey)
 - Fixed bug #51604 (newline in end of header is shown in start of message).
   (Daniel Egeberg)
 - Fixed bug #51590 (JSON_ERROR_UTF8 is undefined). (Felipe)
index bd2cdcb0cfbd14203bf606e173ae10a2533209d7..e8f4d02467edcb086f0f5a0fba21a3c2484f9727 100644 (file)
@@ -562,13 +562,13 @@ void php_mysqli_close(MY_MYSQL * mysql, int close_type TSRMLS_DC)
                                mysqli_plist_entry *plist = (mysqli_plist_entry *) le->ptr;
                                zend_ptr_stack_push(&plist->free_links, mysql->mysql);
 
-                               MyG(num_links)--;
                                MyG(num_active_persistent)--;
                                MyG(num_inactive_persistent)++;
                        }
                }
                mysql->persistent = FALSE;
        }
+       MyG(num_links)--;
        mysql->mysql = NULL;
 
        php_clear_mysql(mysql);
diff --git a/ext/mysqli/tests/bug51605.phpt b/ext/mysqli/tests/bug51605.phpt
new file mode 100644 (file)
index 0000000..d8e5c88
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+Bug #51647 (Certificate file without private key (pk in another file) doesn't work)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--INI--
+mysqli.max_links = 1
+mysqli.allow_persistent = Off
+mysqli.max_persistent = 0
+mysqli.reconnect = Off
+--FILE--
+<?php
+       include ("connect.inc");
+
+       $link = mysqli_init();
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+               printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+       mysqli_close($link);
+       echo "closed once\n";
+
+       $link = mysqli_init();
+       if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+               printf("[002] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+       }
+       mysqli_close($link);
+       echo "closed twice\n";
+
+       print "done!";
+?>
+--EXPECTF--
+closed once
+closed twice
+done!