Annotation of embedaddon/php/ext/mysqli/tests/mysqli_pconnect.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_pconnect()
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_once('skipifconnectfailure.inc');
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: require_once("connect.inc");
! 12:
! 13: $host = 'p:' . $host;
! 14: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 15: printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
! 16: $host, $user, $db, $port, $socket);
! 17:
! 18: mysqli_close($link);
! 19:
! 20: $num = 20;
! 21: $connections = array();
! 22: for ($i = 0; $i < $num; $i++) {
! 23: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 24: printf("[003] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
! 25: $connections[] = $link;
! 26: }
! 27: while (count($connections)) {
! 28: do {
! 29: $index = mt_rand(0, $num);
! 30: } while (!isset($connections[$index]));
! 31: mysqli_close($connections[$index]);
! 32: unset($connections[$index]);
! 33: }
! 34:
! 35:
! 36: $connections = array();
! 37: $num = 20;
! 38: for ($i = 0; $i < $num; $i++) {
! 39: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 40: printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
! 41: $connections[] = $link;
! 42: }
! 43: $left = $num;
! 44:
! 45: while (count($connections) && $left > 0) {
! 46: do {
! 47: $index = mt_rand(0, $num);
! 48: } while (!isset($connections[$index]) && $left > 0);
! 49: if (mt_rand(0, 1) > 0) {
! 50: $left--;
! 51: mysqli_close($connections[$index]);
! 52: unset($connections[$index]);
! 53: } else {
! 54: $left--;
! 55: if (!$connections[$index] = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 56: printf("[004] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
! 57: }
! 58: flush();
! 59: }
! 60:
! 61: while (count($connections)) {
! 62: do {
! 63: $index = mt_rand(0, $num);
! 64: } while (!isset($connections[$index]));
! 65: mysqli_close($connections[$index]);
! 66: unset($connections[$index]);
! 67: }
! 68:
! 69: print "done!";
! 70: ?>
! 71: --EXPECTF--
! 72: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>