diff options
author | Xinchen Hui <laruence@php.net> | 2011-08-24 08:00:23 +0000 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2011-08-24 08:00:23 +0000 |
commit | 344136e8e9d2b3fea54ad7450723c524fe88ef19 (patch) | |
tree | 26a955f44fa5600eb02246985e40e11bd22a433e | |
parent | 04b5bb7d3c5940cd665682c2e6f28b9c7f1044f0 (diff) | |
download | php-git-344136e8e9d2b3fea54ad7450723c524fe88ef19.tar.gz |
Apply r315270 to 5.3
Fixed test script failed when host mysql doesn't listen on 3306
Fxied test script failed due to mysql_pconnect trigger a warning
-rw-r--r-- | ext/mysql/tests/bug55473.phpt | 7 | ||||
-rwxr-xr-x | ext/mysql/tests/mysql_pconn_kill.phpt | 4 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_net.c | 11 |
3 files changed, 20 insertions, 2 deletions
diff --git a/ext/mysql/tests/bug55473.phpt b/ext/mysql/tests/bug55473.phpt index d492e68349..6fafc4cd21 100644 --- a/ext/mysql/tests/bug55473.phpt +++ b/ext/mysql/tests/bug55473.phpt @@ -15,6 +15,11 @@ mysql.allow_persistent=1 <?php include "connect.inc"; + if ($socket) + $host = sprintf("%s:%s", $host, $socket); + else if ($port) + $host = sprintf("%s:%s", $host, $port); + $tmp = NULL; $link = NULL; @@ -68,4 +73,4 @@ OK Warning: mysql_ping(): MySQL server has gone away in %s on line %d reconnect OK -done!
\ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_pconn_kill.phpt b/ext/mysql/tests/mysql_pconn_kill.phpt index 8543e39d6c..20dfbe9a15 100755 --- a/ext/mysql/tests/mysql_pconn_kill.phpt +++ b/ext/mysql/tests/mysql_pconn_kill.phpt @@ -64,7 +64,9 @@ mysql.max_persistent=2 mysql_close($plink); - if (!($plink = mysql_pconnect($myhost, $user, $passwd))) + /* mysql_pconnect cound generate a warning when linked against mysqlnd + PHP Warning: mysql_pconnect(): MySQL server has gone away */ + if (!($plink = @mysql_pconnect($myhost, $user, $passwd))) printf("[009] Cannot create new persistent connection, [%d] %s\n", mysql_errno(), mysql_error()); mysql_select_db($db, $plink); diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index 600a650804..88ce39acd0 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -120,6 +120,17 @@ MYSQLND_METHOD(mysqlnd_net, connect)(MYSQLND_NET * net, const char * const schem net->packet_no = net->compressed_envelope_packet_no = 0; + if (net->stream) { + /* close before opening a new one */ + DBG_INF_FMT("Freeing stream. abstract=%p", net->stream->abstract); + if (net->persistent) { + php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE_PERSISTENT | PHP_STREAM_FREE_RSRC_DTOR); + } else { + php_stream_free(net->stream, PHP_STREAM_FREE_CLOSE); + } + net->stream = NULL; + } + if (net->options.timeout_connect) { tv.tv_sec = net->options.timeout_connect; tv.tv_usec = 0; |