From: Operating system: PHP version: trunk-SVN-2010-07-12 (SVN) Package: Sockets related Bug Type: Bug Bug description:php_network_connect_socket doesn't return all errors correctly
Description: ------------ php_network_connect_socket doesn't return all connection errors (like ECONNREFUSED) correctly in all cases. When error_string is NULL, "ret" isn't set to -1, even when "error" is set. This can cause problems on all platforms. The ftp extension for example will only detect a socket error once it tries to read the socket, instead of directly after the call to php_network_connect_socket. On Windows, an additional problem exists because of the poll() emulation in php_poll2: php_network_connect_socket polls for PHP_POLLREADABLE|POLLOUT, which by php_poll2 is mapped to the readfds and writefds parameters of select(). In winsock however, connect() errors are returned in exceptfds, not in writefds like they are in POSIX. This means the select() call will only return once its timeout has passed and that php_network_connect_socket will incorrectly return PHP_TIMEOUT_ERROR_VALUE. This behaviour causes undesired delays in many functions that (try to) create network connections. An example of this is the long delay that is observed when connecting to a MySQL-server using mysqlnd and a hostname that has both an IPv6 and an IPv4 address: connecting using the IPv6 address will quickly fail, but because of this bug it will take mysql.connect_timeout seconds before the IPv4 address is tried. -- Edit bug report at http://bugs.php.net/bug.php?id=52323&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52323&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52323&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52323&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52323&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52323&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52323&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52323&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52323&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52323&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52323&r=support Expected behavior: http://bugs.php.net/fix.php?id=52323&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52323&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52323&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52323&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52323&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52323&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52323&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52323&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52323&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52323&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52323&r=mysqlcfg