From: Ulf Wendel Date: Mon, 19 Oct 2009 12:09:48 +0000 (+0000) Subject: Fixing host info for TCP/IP and aligning mysqlnd and libmysql X-Git-Tag: php-5.4.0alpha1~191^2~2500 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0949463ed8f2563df9f504b2bd2d726f90d6afbf;p=php Fixing host info for TCP/IP and aligning mysqlnd and libmysql --- diff --git a/ext/mysqli/tests/mysqli_get_host_info.phpt b/ext/mysqli/tests/mysqli_get_host_info.phpt index 63fdad28b4..b3db9be8dc 100644 --- a/ext/mysqli/tests/mysqli_get_host_info.phpt +++ b/ext/mysqli/tests/mysqli_get_host_info.phpt @@ -20,6 +20,11 @@ require_once('skipifconnectfailure.inc'); if (!is_string($info = mysqli_get_host_info($link)) || ('' === $info)) printf("[003] Expecting string/any_non_empty, got %s/%s\n", gettype($info), $info); + if ($IS_MYSQLND && $host != 'localhost' && $host != '127.0.0.1' && $port != '' && $host != "" && strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { + /* this should be a TCP/IP connection and not a Unix Socket (or SHM or Named Pipe) */ + if (!stristr($info, "TCP/IP")) + printf("[004] Should be a TCP/IP connection but mysqlnd says '%s'\n", $info); + } print "done!"; ?> --CLEAN-- diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index e2108461d2..c5e3350cbb 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -728,11 +728,12 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn, conn->user = pestrdup(user, conn->persistent); conn->passwd = pestrndup(passwd, passwd_len, conn->persistent); conn->port = port; - if (host && !socket) { + + if (!unix_socket) { char *p; conn->host = pestrdup(host, conn->persistent); - spprintf(&p, 0, "MySQL host info: %s via TCP/IP", conn->host); + spprintf(&p, 0, "%s via TCP/IP", conn->host); if (conn->persistent) { conn->host_info = pestrdup(p, 1); mnd_efree(p); @@ -741,7 +742,7 @@ PHPAPI MYSQLND *mysqlnd_connect(MYSQLND *conn, } } else { conn->unix_socket = pestrdup(socket, conn->persistent); - conn->host_info = pestrdup("MySQL host info: Localhost via UNIX socket", conn->persistent); + conn->host_info = pestrdup("Localhost via UNIX socket", conn->persistent); } conn->client_flag = auth_packet->client_flags; conn->max_packet_size = auth_packet->max_packet_size;