Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

PHP mysqlnd svn commit: r900 - trunk/tests/ext/mysql

From: <ahristov(at)mysql.com>
Date: Tue Aug 14 2007 - 15:46:27 EDT


Author: ahristov
Date: 2007-08-14 21:46:27 +0200 (Tue, 14 Aug 2007) New Revision: 900

Modified:

   trunk/tests/ext/mysql/mysql_pconn_kill.phpt Log:
Fix test

Modified: trunk/tests/ext/mysql/mysql_pconn_kill.phpt


  • trunk/tests/ext/mysql/mysql_pconn_kill.phpt 2007-08-14 18:59:54 UTC (rev 899) +++ trunk/tests/ext/mysql/mysql_pconn_kill.phpt 2007-08-14 19:46:27 UTC (rev 900) @@ -1,7 +1,7 @@ --TEST-- mysql_pconnect() - killing persitent connection --SKIPIF-- -<?php +<?php require_once('skipif.inc'); require_once('skipifconnectfailure.inc');
    ?>
    @@ -20,15 +20,15 @@ else $myhost = $host;
    • if (!$plink = mysql_pconnect($myhost, $user, $passwd)) + if (!($plink = mysql_pconnect($myhost, $user, $passwd))) printf("[001] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_select_db($db, $plink); - + $pthread_id = mysql_thread_id($plink); $thread_id = mysql_thread_id($link);
    • if (!$res = mysql_query("SHOW FULL PROCESSLIST", $link)) + if (!($res = mysql_query("SHOW FULL PROCESSLIST", $link))) printf("[002] Cannot get processlist, [%d] %s\n", mysql_errno($link), mysql_error($link));

         $processlist = array();
@@ -40,56 +40,59 @@

 		printf("[003] Cannot find regular connection thread in process list, [%d] %s\n", mysql_errno($link), mysql_error($link));
 	if (!isset($processlist[$pthread_id]))
 		printf("[004] Cannot find persistent connection thread in process list, [%d] %s\n", mysql_errno($link), mysql_error($link));
-
-	if (!mysql_query(sprintf("KILL %d", $pthread_id), $link))
+		
+	if (!mysql_query(sprintf("KILL %d", $pthread_id), $link)) 
 		printf("[005] Cannot kill persistent connection thread, [%d] %s\n", mysql_errno($link), mysql_error($link));
 
-	// Give the Server some time to kill the thread
-	sleep(1);
-	if (!$res = mysql_query("SHOW FULL PROCESSLIST", $link))
-		printf("[006] Cannot get processlist, [%d] %s\n", mysql_errno($link), mysql_error($link));
+	while (1) {
+		if (!($res = mysql_query("SHOW FULL PROCESSLIST", $link)))
+			printf("[006] Cannot get processlist, [%d] %s\n", mysql_errno($link), mysql_error($link));
 
-	$processlist2 = array();
-	while ($row = mysql_fetch_assoc($res))
-		$processlist2[$row['Id']] = $row;
-	mysql_free_result($res);
+		$processlist2 = array();
+		while ($row = mysql_fetch_assoc($res))
+			$processlist2[$row['Id']] = $row;
+		mysql_free_result($res);
+		if (isset($processlist2[$pthread_id])) {
+			sleep(1);
+		} else {
+			break;
+		}
+	}
 
 	if (!isset($processlist2[$thread_id]))
 		printf("[007] Cannot find regular connection thread in process list, [%d] %s\n", mysql_errno($link), mysql_error($link));
-	if (isset($processlist2[$pthread_id]))
-		printf("[008] Can still find persistent connection thread in process list, [%d] %s\n", mysql_errno($link), mysql_error($link));
 
 	mysql_close($plink);
 
-	if (!$plink = mysql_pconnect($myhost, $user, $passwd))
+	if (!($plink = mysql_pconnect($myhost, $user, $passwd))) 
 		printf("[009] Cannot create new persistent connection, [%d] %s\n", mysql_errno(), mysql_error());
Do you need help?X
mysql_select_db($db, $plink); - if (!$res = mysql_query("SELECT 1", $plink)); + if (!($res = mysql_query("SELECT 1", $plink))) printf("[010] Cannot run query on new persistent connection, [%d] %s\n", @mysql_errno($plink), @mysql_error($plink)); mysql_free_result($res); var_dump(mysql_ping($plink)); - if (!$res = mysql_query("SELECT 1", $plink)) + if (!($res = mysql_query("SELECT 1", $plink))) printf("[011] Cannot run query on new persistent connection, [%d] %s\n", @mysql_errno($plink), @mysql_error($plink)); mysql_free_result($res); - if (!$link2 = mysql_connect($myhost, $user, $passwd, true)) + if (!($link2 = mysql_connect($myhost, $user, $passwd, true))) printf("[012] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_select_db($db, $link2); - if (!mysql_query(sprintf("KILL %d", $thread_id), $link2)) + if (!mysql_query(sprintf("KILL %d", $thread_id), $link2)) printf("[013] Cannot kill regular connection thread, [%d] %s\n", mysql_errno($link2), mysql_error($link2)); - if (!$link = mysql_connect($myhost, $user, $passwd, true)) + if (!($link = mysql_connect($myhost, $user, $passwd, true))) printf("[014] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $myhost, $user, $db, $port, $socket); mysql_select_db($db, $link); - if (!$res = mysql_query("SELECT * FROM test", $link)); + if (!($res = mysql_query("SELECT * FROM test", $link))) printf("[015] Cannot run query on new regular connection, [%d] %s\n", @mysql_errno($link), @mysql_error($link)); - if (!$res = mysql_query("SELECT * FROM test", $link2));
Do you need more help?X
+ if (!($res = mysql_query("SELECT * FROM test", $link2))) printf("[016] Cannot run query on other regular connection, [%d] %s\n", @mysql_errno($link2), @mysql_error($link2)); mysql_free_result($res); @@ -99,4 +102,5 @@ print "done!";

?>

 --EXPECTF--
-done!
\ No newline at end of file
+bool(true)
+done!
-- 
MySQL Code Commits Mailing List
For list archives: 
http://lists.mysql.com/commits
To unsubscribe:    
http://lists.mysql.com/commits?unsub=lists@pantek.com
Received on Tue Aug 14 15:46:36 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 08:33:23 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library