summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2001-09-19 10:59:12 +0000
committerWez Furlong <wez@php.net>2001-09-19 10:59:12 +0000
commitc6a957e0125d7bba03a2479e17956a067beb80d1 (patch)
tree939c3d8d6c220dbff435cad0b9b8ada63a0260a6
parente4ace6cde6bcebc52aa8f583f7a98b51829de249 (diff)
downloadphp-git-c6a957e0125d7bba03a2479e17956a067beb80d1.tar.gz
Fix silly bugs
-rw-r--r--ext/sockets/sockets.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 34f4c33076..893f57fada 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -543,7 +543,7 @@ PHP_FUNCTION(socket_select)
{
zval **arg1, **arg2, **arg3, **arg4, **arg5;
struct timeval tv;
- php_fd_set *rfds, *wfds, *xfds;
+ php_fd_set *rfds = NULL, *wfds = NULL, *xfds = NULL;
SOCKET max_fd;
int sets = 0;
@@ -580,7 +580,10 @@ PHP_FUNCTION(socket_select)
tv.tv_sec = Z_LVAL_PP(arg4);
tv.tv_usec = Z_LVAL_PP(arg5);
- RETURN_LONG(select(max_fd+1, &(rfds->set), &(wfds->set), &(xfds->set), &tv));
+ RETURN_LONG(select(max_fd+1, rfds ? &(rfds->set) : NULL,
+ wfds ? &(wfds->set) : NULL,
+ xfds ? &(xfds->set) : NULL,
+ &tv));
}
/* }}} */
@@ -682,7 +685,8 @@ PHP_FUNCTION(socket_listen)
backlog = Z_LVAL_PP(arg2);
}
- if (listen(php_sock->bsd_socket, backlog) == 0) {
+ if (listen(php_sock->socket, backlog) != 0) {
+ php_error(E_WARNING, "unable to listen [%d]: %s", errno, strerror(errno));
RETURN_FALSE;
}
@@ -1068,7 +1072,7 @@ PHP_FUNCTION(socket_strerror)
PHP_FUNCTION(socket_bind)
{
zval **arg1, **arg2, **arg3;
- long retval;
+ long retval = 0;
php_sockaddr_storage sa_storage;
struct sockaddr *sock_type = (struct sockaddr*) &sa_storage;
php_socket *php_sock;
@@ -1119,7 +1123,7 @@ PHP_FUNCTION(socket_bind)
}
if (retval != 0) {
- php_error(E_WARNING, "unable to bind address, %i", errno);
+ php_error(E_WARNING, "unable to bind address, [%i] %s", errno, strerror(errno));
RETURN_FALSE;
}