]> 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)
ext/mysqli/mysqli_api.c
ext/mysqli/tests/bug51605.phpt [new file with mode: 0644]

index bd2cdcb0cfbd14203bf606e173ae10a2533209d7..4be3e3baf740a0de814deea3077c4b8ad08cf039 100644 (file)
@@ -562,7 +562,6 @@ 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)++;
                        }
@@ -570,6 +569,7 @@ void php_mysqli_close(MY_MYSQL * mysql, int close_type TSRMLS_DC)
                mysql->persistent = FALSE;
        }
        mysql->mysql = NULL;
+       MyG(num_links)--;
 
        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!