[PHP-CVS] cvs: php-src /main network.c /main/streams xp_socket.c
andrey Mon Mar 10 19:55:43 2008 UTC Modified files: /php-src/main network.c /php-src/main/streams xp_socket.c Log: char **error_message was passed but not used. This causes problems in cases of getaddrinfo() failure, because the upper layers don't get the error. initialize a variable because we were reading initialized in case of error. http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.131&r2=1.132&diff_format=u Index: php-src/main/network.c diff -u php-src/main/network.c:1.131 php-src/main/network.c:1.132 --- php-src/main/network.c:1.131Mon Dec 31 07:12:18 2007 +++ php-src/main/network.c Mon Mar 10 19:55:43 2008 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: network.c,v 1.131 2007/12/31 07:12:18 sebastian Exp $ */ +/* $Id: network.c,v 1.132 2008/03/10 19:55:43 andrey Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -205,10 +205,12 @@ # endif if ((n = getaddrinfo(host, NULL, &hints, &res))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n)); + spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string); return 0; } else if (res == NULL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed (null result pointer)"); + spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed (null result pointer) errno=%d", errno); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string); return 0; } @@ -232,7 +234,8 @@ /* XXX NOT THREAD SAFE (is safe under win32) */ host_info = gethostbyname(host); if (host_info == NULL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: gethostbyname failed"); + spprintf(error_string, 0, "php_network_getaddresses: gethostbyname failed. errno=%d", errno); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string); return 0; } in = *((struct in_addr *) host_info->h_addr); http://cvs.php.net/viewvc.cgi/php-src/main/streams/xp_socket.c?r1=1.44&r2=1.45&diff_format=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.44 php-src/main/streams/xp_socket.c:1.45 --- php-src/main/streams/xp_socket.c:1.44 Wed Feb 27 00:30:49 2008 +++ php-src/main/streams/xp_socket.cMon Mar 10 19:55:43 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.44 2008/02/27 00:30:49 iliaa Exp $ */ +/* $Id: xp_socket.c,v 1.45 2008/03/10 19:55:43 andrey Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -601,7 +601,7 @@ { char *host = NULL, *bindto = NULL; int portno, bindport = 0; - int err; + int err = 0; int ret; zval **tmpzval = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /main network.c /main/streams xp_socket.c /win32/build config.w32
wez Fri Sep 17 10:36:55 2004 EDT Modified files: /php-src/main network.c /php-src/main/streams xp_socket.c /php-src/win32/buildconfig.w32 Log: Make new poll stuff work on win32 (and still be safe on unix) http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.112&r2=1.113&ty=u Index: php-src/main/network.c diff -u php-src/main/network.c:1.112 php-src/main/network.c:1.113 --- php-src/main/network.c:1.112Fri Sep 17 08:44:56 2004 +++ php-src/main/network.c Fri Sep 17 10:36:54 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: network.c,v 1.112 2004/09/17 12:44:56 wez Exp $ */ +/* $Id: network.c,v 1.113 2004/09/17 14:36:54 wez Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -1047,7 +1047,7 @@ php_socket_t max_fd = SOCK_ERR; unsigned int i, n; struct timeval tv; - + /* check the highest numbered descriptor */ for (i = 0; i < nfds; i++) { if (ufds[i].fd > max_fd) @@ -1061,19 +1061,14 @@ FD_ZERO(&eset); for (i = 0; i < nfds; i++) { - if (ufds[i].fd >= FD_SETSIZE) { - /* unsafe to set */ - ufds[i].revents = POLLNVAL; - continue; - } if (ufds[i].events & PHP_POLLREADABLE) { - FD_SET(ufds[i].fd, &rset); + PHP_SAFE_FD_SET(ufds[i].fd, &rset); } if (ufds[i].events & POLLOUT) { - FD_SET(ufds[i].fd, &wset); + PHP_SAFE_FD_SET(ufds[i].fd, &wset); } if (ufds[i].events & POLLPRI) { - FD_SET(ufds[i].fd, &eset); + PHP_SAFE_FD_SET(ufds[i].fd, &eset); } } @@ -1081,30 +1076,24 @@ tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000; } - n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL); if (n >= 0) { for (i = 0; i < nfds; i++) { - if (ufds[i].fd >= FD_SETSIZE) { - continue; - } - ufds[i].revents = 0; - if (FD_ISSET(ufds[i].fd, &rset)) { + if (PHP_SAFE_FD_ISSET(ufds[i].fd, &rset)) { /* could be POLLERR or POLLHUP but can't tell without probing */ ufds[i].revents |= POLLIN; } - if (FD_ISSET(ufds[i].fd, &wset)) { + if (PHP_SAFE_FD_ISSET(ufds[i].fd, &wset)) { ufds[i].revents |= POLLOUT; } - if (FD_ISSET(ufds[i].fd, &eset)) { + if (PHP_SAFE_FD_ISSET(ufds[i].fd, &eset)) { ufds[i].revents |= POLLPRI; } } } - return n; } http://cvs.php.net/diff.php/php-src/main/streams/xp_socket.c?r1=1.29&r2=1.30&ty=u Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.29 php-src/main/streams/xp_socket.c:1.30 --- php-src/main/streams/xp_socket.c:1.29 Fri Sep 17 08:44:56 2004 +++ php-src/main/streams/xp_socket.cFri Sep 17 10:36:55 2004 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.29 2004/09/17 12:44:56 wez Exp $ */ +/* $Id: xp_socket.c,v 1.30 2004/09/17 14:36:55 wez Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -126,6 +126,9 @@ sock->timeout_event = 1; if (retval >= 0) + break; + + if (php_socket_errno() != EINTR) break; } } http://cvs.php.net/diff.php/php-src/win32/build/config.w32?r1=1.31&r2=1.32&ty=u Index: php-src/win32/build/config.w32 diff -u php-src/win32/build/config.w32:1.31 php-src/win32/build/config.w32:1.32 --- php-src/win32/build/config.w32:1.31 Fri Sep 17 08:44:56 2004 +++ php-src/win32/build/config.w32 Fri Sep 17 10:36:55 2004 @@ -1,5 +1,5 @@ // vim:ft=javascript -// $Id: config.w32,v 1.31 2004/09/17 12:44:56 wez Exp $ +// $Id: config.w32,v 1.32 2004/09/17 14:36:55 wez Exp $ // "Master" config file; think of it as a configure.in // equivalent. @@ -218,7 +218,7 @@ /* this allows up to 256 sockets to be select()ed in a single * call to select(), instead of the usual 64 */ ARG_ENABLE('fd-setsize', "Set maximum number of sockets for select(2)", "256"); -AC_DEFINE('FD_SETSIZE', PHP_FD_SETSIZE); +ADD_FLAG("CFLAGS", "/D FD_SETSIZE=" + parseInt(PHP_FD_SETSIZE)); ARG_ENABLE("memory-limit", "Enable memory limit checking code", "no"); -- PHP CVS Maili
[PHP-CVS] cvs: php-src /main network.c /main/streams xp_socket.c
iliaa Sun Nov 30 14:43:30 2003 EDT Modified files: /php-src/main network.c /php-src/main/streams xp_socket.c Log: Removed unused variables. Index: php-src/main/network.c diff -u php-src/main/network.c:1.104 php-src/main/network.c:1.105 --- php-src/main/network.c:1.104Sat Nov 29 16:46:49 2003 +++ php-src/main/network.c Sun Nov 30 14:43:28 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: network.c,v 1.104 2003/11/29 21:46:49 wez Exp $ */ +/* $Id: network.c,v 1.105 2003/11/30 19:43:28 iliaa Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -481,17 +481,14 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, long addrlen, struct sockaddr *sa, socklen_t *sl TSRMLS_DC) { char *colon; - char *host = NULL; - int is_v6; char *tmp; int ret = FAILURE; short port; struct sockaddr_in *in4 = (struct sockaddr_in*)sa; - struct sockaddr **sal, **psal; + struct sockaddr **psal; int n; char *errstr = NULL; #ifdef HAVE_IPV6 - char *p; struct sockaddr_in6 *in6 = (struct sockaddr_in6*)sa; #endif Index: php-src/main/streams/xp_socket.c diff -u php-src/main/streams/xp_socket.c:1.18 php-src/main/streams/xp_socket.c:1.19 --- php-src/main/streams/xp_socket.c:1.18 Sat Nov 29 16:46:50 2003 +++ php-src/main/streams/xp_socket.cSun Nov 30 14:43:30 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: xp_socket.c,v 1.18 2003/11/29 21:46:50 wez Exp $ */ +/* $Id: xp_socket.c,v 1.19 2003/11/30 19:43:30 iliaa Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -141,9 +141,11 @@ static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC) { php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; +#ifdef PHP_WIN32 fd_set wrfds, efds; int n; struct timeval timeout; +#endif if (close_handle) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php