[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/main/network.c trunk/main/network.c

2010-10-02 Thread Gustavo André dos Santos Lopes
cataphract   Sat, 02 Oct 2010 18:32:20 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=303958

Log:
- Fixed a small mistake in the fix for bug #50953 that made connection timeouts 
not be detected as such.

Bug: http://bugs.php.net/50953 (Closed) fsockopen will not work on 'localhost'
  
Changed paths:
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/main/network.c
===
--- php/php-src/branches/PHP_5_3/main/network.c 2010-10-02 17:00:49 UTC (rev 
303957)
+++ php/php-src/branches/PHP_5_3/main/network.c 2010-10-02 18:32:20 UTC (rev 
303958)
@@ -342,14 +342,14 @@
 * 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,
+* expected 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) {
+#endif
error = PHP_TIMEOUT_ERROR_VALUE;
-#endif
}

if (n  0) {

Modified: php/php-src/trunk/main/network.c
===
--- php/php-src/trunk/main/network.c2010-10-02 17:00:49 UTC (rev 303957)
+++ php/php-src/trunk/main/network.c2010-10-02 18:32:20 UTC (rev 303958)
@@ -342,14 +342,14 @@
 * 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,
+* expected 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) {
+#endif
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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/main/network.c trunk/main/network.c

2010-09-08 Thread Pierre Joye
pajoye   Wed, 08 Sep 2010 10:25:40 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=303166

Log:
- Fix bug #52323, return value of php_network_connect_socket should be set even 
if the caller does not care about the error_string

Bug: http://bugs.php.net/52323 (Feedback) php_network_connect_socket doesn't 
return all errors correctly
  
Changed paths:
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/main/network.c
===
--- php/php-src/branches/PHP_5_3/main/network.c 2010-09-08 09:57:20 UTC (rev 
303165)
+++ php/php-src/branches/PHP_5_3/main/network.c 2010-09-08 10:25:40 UTC (rev 
303166)
@@ -377,8 +377,10 @@
}

if (error  error_string) {
-   *error_string = php_socket_strerror(error, NULL, 0);
ret = -1;
+   if (error_string) {
+   *error_string = php_socket_strerror(error, NULL, 0);
+   }
}
return ret;
 #else

Modified: php/php-src/trunk/main/network.c
===
--- php/php-src/trunk/main/network.c2010-09-08 09:57:20 UTC (rev 303165)
+++ php/php-src/trunk/main/network.c2010-09-08 10:25:40 UTC (rev 303166)
@@ -377,8 +377,10 @@
}

if (error  error_string) {
-   *error_string = php_socket_strerror(error, NULL, 0);
ret = -1;
+   if (error_string) {
+   *error_string = php_socket_strerror(error, NULL, 0);
+   }
}
return ret;
 #else

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/main/network.c trunk/main/network.c

2010-09-08 Thread Pierre Joye
pajoye   Wed, 08 Sep 2010 10:26:59 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=303167

Log:
- WS

Changed paths:
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/main/network.c
===
--- php/php-src/branches/PHP_5_3/main/network.c	2010-09-08 10:25:40 UTC (rev 303166)
+++ php/php-src/branches/PHP_5_3/main/network.c	2010-09-08 10:26:59 UTC (rev 303167)
@@ -125,7 +125,7 @@
 {EAI_MEMORY, Memory allocation failure},
 #  ifdef EAI_NODATA
 {EAI_NODATA, No address associated with hostname},
-#  endif
+#  endif
 {EAI_NONAME, Name or service not known},
 {EAI_SERVICE, Servname not supported for ai_socktype},
 {EAI_SOCKTYPE, ai_socktype not supported},
@@ -139,7 +139,7 @@
 return (char *)values[i].msg;
 }
 }
-
+
 return Unknown error;
 }
 /* }}} */
@@ -182,10 +182,10 @@
 	}
 #if HAVE_GETADDRINFO
 	memset(hints, '\0', sizeof(hints));
-
+
 	hints.ai_family = AF_INET; /* default to regular inet (see below) */
 	hints.ai_socktype = socktype;
-
+
 # if HAVE_IPV6
 	/* probe for a working IPv6 stack; even if detected as having v6 at compile
 	 * time, at runtime some stacks are slow to resolve or have other issues
@@ -228,17 +228,17 @@
 	sai = res;
 	for (n = 1; (sai = sai-ai_next) != NULL; n++)
 		;
-
+
 	*sal = safe_emalloc((n + 1), sizeof(*sal), 0);
 	sai = res;
 	sap = *sal;
-
+
 	do {
 		*sap = emalloc(sai-ai_addrlen);
 		memcpy(*sap, sai-ai_addr, sai-ai_addrlen);
 		sap++;
 	} while ((sai = sai-ai_next) != NULL);
-
+
 	freeaddrinfo(res);
 #else
 	if (!inet_aton(host, in)) {
@@ -313,7 +313,7 @@
 	int ret = 0;

 	SET_SOCKET_BLOCKING_MODE(sockfd, orig_flags);
-
+
 	if ((n = connect(sockfd, addr, addrlen)) != 0) {
 		error = php_socket_errno();

@@ -459,14 +459,14 @@

 		if (sa) {
 			/* attempt to bind */
-
+
 #ifdef SO_REUSEADDR
 			{
 int val = 1;
 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)val, sizeof(val));
 			}
 #endif
-
+
 			n = bind(sock, sa, socklen);

 			if (n != SOCK_CONN_ERR) {
@@ -486,13 +486,13 @@
 	if (error_string) {
 		*error_string = php_socket_strerror(err, NULL, 0);
 	}
-
+
 bound:

 	php_network_freeaddresses(psal);
-
+
 	return sock;
-
+
 }
 /* }}} */

@@ -610,7 +610,7 @@
 /* generally not thread safe, but it *is* thread safe under win32 */
 buf = inet_ntoa(((struct sockaddr_in*)sa)-sin_addr);
 if (buf) {
-	*textaddrlen = spprintf(textaddr, 0, %s:%d,
+	*textaddrlen = spprintf(textaddr, 0, %s:%d,
 		buf, ntohs(((struct sockaddr_in*)sa)-sin_port));
 }

@@ -620,7 +620,7 @@
 			case AF_INET6:
 buf = (char*)inet_ntop(sa-sa_family, ((struct sockaddr_in6*)sa)-sin6_addr, (char *)abuf, sizeof(abuf));
 if (buf) {
-	*textaddrlen = spprintf(textaddr, 0, %s:%d,
+	*textaddrlen = spprintf(textaddr, 0, %s:%d,
 		buf, ntohs(((struct sockaddr_in6*)sa)-sin6_port));
 }

@@ -651,7 +651,7 @@
 	}
 }

-PHPAPI int php_network_get_peer_name(php_socket_t sock,
+PHPAPI int php_network_get_peer_name(php_socket_t sock,
 		char **textaddr, long *textaddrlen,
 		struct sockaddr **addr,
 		socklen_t *addrlen
@@ -660,7 +660,7 @@
 	php_sockaddr_storage sa;
 	socklen_t sl = sizeof(sa);
 	memset(sa, 0, sizeof(sa));
-
+
 	if (getpeername(sock, (struct sockaddr*)sa, sl) == 0) {
 		php_network_populate_name_from_sockaddr((struct sockaddr*)sa, sl,
 textaddr, textaddrlen,
@@ -671,7 +671,7 @@
 	return -1;
 }

-PHPAPI int php_network_get_sock_name(php_socket_t sock,
+PHPAPI int php_network_get_sock_name(php_socket_t sock,
 		char **textaddr, long *textaddrlen,
 		struct sockaddr **addr,
 		socklen_t *addrlen
@@ -680,7 +680,7 @@
 	php_sockaddr_storage sa;
 	socklen_t sl = sizeof(sa);
 	memset(sa, 0, sizeof(sa));
-
+
 	if (getsockname(sock, (struct sockaddr*)sa, sl) == 0) {
 		php_network_populate_name_from_sockaddr((struct sockaddr*)sa, sl,
 textaddr, textaddrlen,
@@ -715,7 +715,7 @@
 	int error = 0, n;
 	php_sockaddr_storage sa;
 	socklen_t sl;
-
+
 	n = php_pollfd_for(srvsock, PHP_POLLREADABLE, timeout);

 	if (n == 0) {
@@ -736,20 +736,20 @@
 			error = php_socket_errno();
 		}
 	}
-
+
 	if (error_code) {
 		*error_code = error;
 	}
 	if (error_string) {
 		*error_string = php_socket_strerror(error, NULL, 0);
 	}
-
+
 	return clisock;
 }
 /* }}} */
-


+
 /* Connect to a remote host using an interruptible connect with optional timeout.
  * Optionally, the connect can be made asynchronously, which will implicitly
  * enable non-blocking mode on the socket.
@@ -759,7 +759,7 @@
 /* {{{ php_network_connect_socket_to_host */
 php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
 		int socktype, int asynchronous, struct timeval *timeout, char **error_string,
-		int *error_code, char *bindto, unsigned short 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/main/network.c trunk/main/network.c

2010-09-08 Thread Pierre Joye
pajoye   Wed, 08 Sep 2010 11:51:11 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=303172

Log:
- fix the fix for bug #52323

Bug: http://bugs.php.net/52323 (Feedback) php_network_connect_socket doesn't 
return all errors correctly
  
Changed paths:
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/main/network.c
===
--- php/php-src/branches/PHP_5_3/main/network.c 2010-09-08 11:47:10 UTC (rev 
303171)
+++ php/php-src/branches/PHP_5_3/main/network.c 2010-09-08 11:51:11 UTC (rev 
303172)
@@ -376,7 +376,7 @@
*error_code = error;
}

-   if (error  error_string) {
+   if (error) {
ret = -1;
if (error_string) {
*error_string = php_socket_strerror(error, NULL, 0);

Modified: php/php-src/trunk/main/network.c
===
--- php/php-src/trunk/main/network.c2010-09-08 11:47:10 UTC (rev 303171)
+++ php/php-src/trunk/main/network.c2010-09-08 11:51:11 UTC (rev 303172)
@@ -376,7 +376,7 @@
*error_code = error;
}

-   if (error  error_string) {
+   if (error) {
ret = -1;
if (error_string) {
*error_string = php_socket_strerror(error, NULL, 0);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php