pajoye Tue, 07 Sep 2010 09:47:36 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=303129
Log: - fix bug #50953, socket will not connect to IPv4 address when the host has both ipv4 and ipv6 addresses Bug: http://bugs.php.net/50953 (Assigned) fsockopen will not work on 'localhost' Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/main/network.c U php/php-src/trunk/main/network.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-09-07 04:40:24 UTC (rev 303128) +++ php/php-src/branches/PHP_5_3/NEWS 2010-09-07 09:47:36 UTC (rev 303129) @@ -72,6 +72,8 @@ - Fixed bug #50481 (Storing many SPLFixedArray in an array crashes). (Felipe) - Fixed bug #52260 (dns_get_record fails with non-existing domain on Windows). (a_jelly_doughnut at phpbb dot com, Pierre) +- Fixed #50953, socket will not connect to IPv4 address when the host has both + IPv4 and IPv6 addresses, on Windows. (Gustavo, Pierre) 22 Jul 2010, PHP 5.3.3 - Upgraded bundled sqlite to version 3.6.23.1. (Ilia) Modified: php/php-src/branches/PHP_5_3/main/network.c =================================================================== --- php/php-src/branches/PHP_5_3/main/network.c 2010-09-07 04:40:24 UTC (rev 303128) +++ php/php-src/branches/PHP_5_3/main/network.c 2010-09-07 09:47:36 UTC (rev 303129) @@ -206,7 +206,7 @@ } hints.ai_family = ipv6_borked ? AF_INET : AF_UNSPEC; # endif - + if ((n = getaddrinfo(host, NULL, &hints, &res))) { if (error_string) { spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n)); @@ -337,9 +337,19 @@ if (n == 0) { goto ok; } - +# ifdef PHP_WIN32 + /* The documentation for connect() says in case of non-blocking connections + * the select function reports success in the writefds set and failure in + * the exceptfds set. Indeed, using PHP_POLLREADABLE results in select + * failing only due to the timeout and not immediately as would be + * exepected when a connection is actively refused. This way, + * php_pollfd_for will return a mask with POLLOUT if the connection + * is successful and with POLLPRI otherwise. */ + if ((n = php_pollfd_for(sockfd, POLLOUT|POLLPRI, timeout)) == 0) { +#else if ((n = php_pollfd_for(sockfd, PHP_POLLREADABLE|POLLOUT, timeout)) == 0) { error = PHP_TIMEOUT_ERROR_VALUE; +#endif } if (n > 0) { Modified: php/php-src/trunk/main/network.c =================================================================== --- php/php-src/trunk/main/network.c 2010-09-07 04:40:24 UTC (rev 303128) +++ php/php-src/trunk/main/network.c 2010-09-07 09:47:36 UTC (rev 303129) @@ -337,9 +337,19 @@ if (n == 0) { goto ok; } - +# ifdef PHP_WIN32 + /* The documentation for connect() says in case of non-blocking connections + * the select function reports success in the writefds set and failure in + * the exceptfds set. Indeed, using PHP_POLLREADABLE results in select + * failing only due to the timeout and not immediately as would be + * exepected when a connection is actively refused. This way, + * php_pollfd_for will return a mask with POLLOUT if the connection + * is successful and with POLLPRI otherwise. */ + if ((n = php_pollfd_for(sockfd, POLLOUT|POLLPRI, timeout)) == 0) { +#else if ((n = php_pollfd_for(sockfd, PHP_POLLREADABLE|POLLOUT, timeout)) == 0) { error = PHP_TIMEOUT_ERROR_VALUE; +#endif } if (n > 0) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php