]> granicus.if.org Git - php/commitdiff
Apply r315270 to 5.3
authorXinchen Hui <laruence@php.net>
Wed, 24 Aug 2011 08:00:23 +0000 (08:00 +0000)
committerXinchen Hui <laruence@php.net>
Wed, 24 Aug 2011 08:00:23 +0000 (08:00 +0000)
Fixed test script failed when host mysql doesn't listen on 3306
Fxied test script failed due to mysql_pconnect trigger a warning

ext/mysql/tests/bug55473.phpt
ext/mysql/tests/mysql_pconn_kill.phpt
ext/mysqlnd/mysqlnd_net.c

index d492e68349b5aabb1bb143432d50f8edd759d699..6fafc4cd215a0796a9c13ac4f5e1ee0487a99421 100644 (file)
@@ -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!
index 8543e39d6c2f8b5ed0120f7afcbd0a7640461e88..20dfbe9a15adcdba16376edc7585cde53bf099e3 100755 (executable)
@@ -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);
 
index 600a650804e076bf4e3527c56a8623a45a3087cc..88ce39acd023bc8298f3e7f680c4e05262509e16 100644 (file)
@@ -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;