summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2013-02-04 14:15:58 +0100
committerAndrey Hristov <andrey@php.net>2013-02-04 14:15:58 +0100
commit643ce95b5bd80e744c7f5e6ac33138f40ed9a1f7 (patch)
tree52244685f5fec1eb87858901cd97f5abf2f8d805
parentf45a85c3861325c0ec5f5f5f7af01e4de1545189 (diff)
parent0110662ae9e89d21c119b3287118e82fd435f779 (diff)
downloadphp-git-643ce95b5bd80e744c7f5e6ac33138f40ed9a1f7.tar.gz
Merge branch 'PHP-5.4' of ssh://git.php.net/php-src into PHP-5.4
-rw-r--r--NEWS3
-rw-r--r--ext/snmp/snmp.c2
-rw-r--r--ext/sockets/php_sockets.h43
-rw-r--r--ext/sockets/sockets.c49
-rw-r--r--ext/sockets/tests/ipv6_skipif.inc6
-rw-r--r--ext/sockets/tests/socket_import_stream-4-win.phpt3
-rw-r--r--ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt62
-rw-r--r--ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt3
-rw-r--r--main/network.c5
-rw-r--r--sapi/cli/php_cli_server.c30
10 files changed, 128 insertions, 78 deletions
diff --git a/NEWS b/NEWS
index 2fc746e3fe..2aff180fa9 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2012, PHP 5.4.13
+- CLI server:
+ . Fixed bug #64128 (buit-in web server is broken on ppc64). (Remi)
+
?? ??? 2012, PHP 5.4.12
- Core:
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 926b666955..037fcce825 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -1135,7 +1135,7 @@ static int netsnmp_session_init(php_snmp_session **session_p, int version, char
}
*pptr = '\0';
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "mailformed IPv6 address, closing square bracket missing");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "malformed IPv6 address, closing square bracket missing");
return (-1);
}
} else { /* IPv4 address */
diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h
index df205e5114..fabc9c4c3e 100644
--- a/ext/sockets/php_sockets.h
+++ b/ext/sockets/php_sockets.h
@@ -37,41 +37,6 @@ extern zend_module_entry sockets_module_entry;
#endif
#endif
-PHP_MINIT_FUNCTION(sockets);
-PHP_MINFO_FUNCTION(sockets);
-PHP_RSHUTDOWN_FUNCTION(sockets);
-
-PHP_FUNCTION(socket_select);
-PHP_FUNCTION(socket_create_listen);
-#ifdef HAVE_SOCKETPAIR
-PHP_FUNCTION(socket_create_pair);
-#endif
-PHP_FUNCTION(socket_accept);
-PHP_FUNCTION(socket_set_nonblock);
-PHP_FUNCTION(socket_set_block);
-PHP_FUNCTION(socket_listen);
-PHP_FUNCTION(socket_close);
-PHP_FUNCTION(socket_write);
-PHP_FUNCTION(socket_read);
-PHP_FUNCTION(socket_getsockname);
-PHP_FUNCTION(socket_getpeername);
-PHP_FUNCTION(socket_create);
-PHP_FUNCTION(socket_connect);
-PHP_FUNCTION(socket_strerror);
-PHP_FUNCTION(socket_bind);
-PHP_FUNCTION(socket_recv);
-PHP_FUNCTION(socket_send);
-PHP_FUNCTION(socket_recvfrom);
-PHP_FUNCTION(socket_sendto);
-PHP_FUNCTION(socket_get_option);
-PHP_FUNCTION(socket_set_option);
-#ifdef HAVE_SHUTDOWN
-PHP_FUNCTION(socket_shutdown);
-#endif
-PHP_FUNCTION(socket_last_error);
-PHP_FUNCTION(socket_clear_error);
-PHP_FUNCTION(socket_import_stream);
-
#ifndef PHP_WIN32
typedef int PHP_SOCKET;
# define PHP_SOCKETS_API PHPAPI
@@ -99,14 +64,6 @@ PHP_SOCKETS_API int php_sockets_le_socket(void);
#define php_sockets_le_socket_name "Socket"
-/* Prototypes */
-#ifdef ilia_0 /* not needed, only causes a compiler warning */
-static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC);
-static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC);
-static int php_read(php_socket *sock, void *buf, size_t maxlen, int flags);
-static char *php_strerror(int error TSRMLS_DC);
-#endif
-
ZEND_BEGIN_MODULE_GLOBALS(sockets)
int last_error;
char *strerror_buf;
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 43bae9f661..06bd0ec6b4 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -114,13 +114,17 @@ static PHP_GINIT_FUNCTION(sockets);
static char *php_strerror(int error TSRMLS_DC);
+#define PHP_SOCKET_ERROR(socket, msg, errn) \
+ do { \
+ int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \
+ (socket)->error = _err; \
+ SOCKETS_G(last_error) = _err; \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, _err, php_strerror(_err TSRMLS_CC)); \
+ } while (0)
+
#define PHP_NORMAL_READ 0x0001
#define PHP_BINARY_READ 0x0002
-#define PHP_SOCKET_ERROR(socket,msg,errn) socket->error = errn; \
- SOCKETS_G(last_error) = errn; \
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s [%d]: %s", msg, errn, php_strerror(errn TSRMLS_CC))
-
static int le_socket;
#define le_socket_name php_sockets_le_socket_name
@@ -279,6 +283,41 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_import_stream, 0, 0, 1)
ZEND_END_ARG_INFO()
/* }}} */
+PHP_MINIT_FUNCTION(sockets);
+PHP_MINFO_FUNCTION(sockets);
+PHP_RSHUTDOWN_FUNCTION(sockets);
+
+PHP_FUNCTION(socket_select);
+PHP_FUNCTION(socket_create_listen);
+#ifdef HAVE_SOCKETPAIR
+PHP_FUNCTION(socket_create_pair);
+#endif
+PHP_FUNCTION(socket_accept);
+PHP_FUNCTION(socket_set_nonblock);
+PHP_FUNCTION(socket_set_block);
+PHP_FUNCTION(socket_listen);
+PHP_FUNCTION(socket_close);
+PHP_FUNCTION(socket_write);
+PHP_FUNCTION(socket_read);
+PHP_FUNCTION(socket_getsockname);
+PHP_FUNCTION(socket_getpeername);
+PHP_FUNCTION(socket_create);
+PHP_FUNCTION(socket_connect);
+PHP_FUNCTION(socket_strerror);
+PHP_FUNCTION(socket_bind);
+PHP_FUNCTION(socket_recv);
+PHP_FUNCTION(socket_send);
+PHP_FUNCTION(socket_recvfrom);
+PHP_FUNCTION(socket_sendto);
+PHP_FUNCTION(socket_get_option);
+PHP_FUNCTION(socket_set_option);
+#ifdef HAVE_SHUTDOWN
+PHP_FUNCTION(socket_shutdown);
+#endif
+PHP_FUNCTION(socket_last_error);
+PHP_FUNCTION(socket_clear_error);
+PHP_FUNCTION(socket_import_stream);
+
/* {{{ sockets_functions[]
*/
const zend_function_entry sockets_functions[] = {
@@ -1095,7 +1134,7 @@ PHP_FUNCTION(socket_set_nonblock)
if (stream != NULL) {
if (php_stream_set_option(stream, PHP_STREAM_OPTION_BLOCKING, 0,
NULL) != -1) {
- php_sock->blocking = 1;
+ php_sock->blocking = 0;
RETURN_TRUE;
}
}
diff --git a/ext/sockets/tests/ipv6_skipif.inc b/ext/sockets/tests/ipv6_skipif.inc
index ad8cf77b35..1f824630cb 100644
--- a/ext/sockets/tests/ipv6_skipif.inc
+++ b/ext/sockets/tests/ipv6_skipif.inc
@@ -2,7 +2,5 @@
if (!defined("AF_INET6")) {
die('skip no IPv6 support');
}
-/* If IPv6 is supported on the platform this will error out with code 111 - Connection refused.
- If IPv6 is NOT supported, $errno will be set to something else (indicating parse/getaddrinfo error) */
-@stream_socket_client('tcp://[::1]:0', $errno);
-if ($errno != 111) die('skip no IPv6 support');
+if (@stream_socket_client('udp://[::1]:8888') === false)
+ die('skip no IPv6 support');
diff --git a/ext/sockets/tests/socket_import_stream-4-win.phpt b/ext/sockets/tests/socket_import_stream-4-win.phpt
index e2fc523ce5..b36764f617 100644
--- a/ext/sockets/tests/socket_import_stream-4-win.phpt
+++ b/ext/sockets/tests/socket_import_stream-4-win.phpt
@@ -80,9 +80,6 @@ stream_set_blocking
Warning: stream_set_blocking(): %d is not a valid stream resource in %s on line %d
socket_set_block
-Warning: socket_set_block(): An operation was attempted on something that is not a socket.
- in %ssocket_import_stream-4-win.php on line %d
-
Warning: socket_set_block(): unable to set blocking mode [%d]: An operation was attempted on something that is not a socket.
in %ssocket_import_stream-4-win.php on line %d
diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt
new file mode 100644
index 0000000000..ec965094bc
--- /dev/null
+++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp-win32.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Test if socket_recvfrom() receives data sent by socket_sendto() via IPv6 UDP (Win32)
+--SKIPIF--
+<?php
+if (!extension_loaded('sockets')) {
+ die('SKIP The sockets extension is not loaded.');
+}
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only for Windows');
+}
+require 'ipv6_skipif.inc';
+--FILE--
+<?php
+ $socket = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
+ if (!$socket) {
+ die('Unable to create AF_INET6 socket');
+ }
+ if (!socket_set_nonblock($socket)) {
+ die('Unable to set nonblocking mode for socket');
+ }
+ socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning
+ $address = '::1';
+ socket_sendto($socket, '', 1, 0, $address); // cause warning
+ if (!socket_bind($socket, $address, 1223)) {
+ die("Unable to bind to $address:1223");
+ }
+
+ $msg = "Ping!";
+ $len = strlen($msg);
+ $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address, 1223);
+ if ($bytes_sent == -1) {
+ die('An error occurred while sending to the socket');
+ } else if ($bytes_sent != $len) {
+ die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' bytes expected');
+ }
+
+ $from = "";
+ $port = 0;
+ socket_recvfrom($socket, $buf, 12, 0); // cause warning
+ socket_recvfrom($socket, $buf, 12, 0, $from); // cause warning
+ $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from, $port);
+ if ($bytes_received == -1) {
+ die('An error occurred while receiving from the socket');
+ } else if ($bytes_received != $len) {
+ die($bytes_received . ' bytes have been received instead of the ' . $len . ' bytes expected');
+ }
+ echo "Received $buf from remote address $from and remote port $port" . PHP_EOL;
+
+ socket_close($socket);
+--EXPECTF--
+Warning: socket_recvfrom(): unable to recvfrom [10022]: An invalid argument was supplied.
+ in %s on line %d
+
+Warning: Wrong parameter count for socket_sendto() in %s on line %d
+
+Warning: socket_recvfrom() expects at least 5 parameters, 4 given in %s on line %d
+
+Warning: Wrong parameter count for socket_recvfrom() in %s on line %d
+Received Ping! from remote address ::1 and remote port 1223
+--CREDITS--
+Falko Menge <mail at falko-menge dot de>
+PHP Testfest Berlin 2009-05-09
diff --git a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt
index 04f62eddd3..2beb8080cd 100644
--- a/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt
+++ b/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt
@@ -5,6 +5,9 @@ Test if socket_recvfrom() receives data sent by socket_sendto() via IPv6 UDP
if (!extension_loaded('sockets')) {
die('SKIP The sockets extension is not loaded.');
}
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not valid for Windows');
+}
require 'ipv6_skipif.inc';
--FILE--
<?php
diff --git a/main/network.c b/main/network.c
index 4b7a8d410a..ba2ee1c498 100644
--- a/main/network.c
+++ b/main/network.c
@@ -1076,11 +1076,6 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC)
/* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */
flags = !block;
if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) {
- char *error_string;
-
- error_string = php_socket_strerror(WSAGetLastError(), NULL, 0);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", error_string);
- efree(error_string);
ret = FAILURE;
}
#else
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 28aba198f5..6a4e7c53ab 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -710,10 +710,9 @@ static void php_cli_server_poller_remove(php_cli_server_poller *poller, int mode
if (fd == poller->max_fd) {
while (fd > 0) {
fd--;
- if (((unsigned int *)&poller->rfds)[fd / (8 * sizeof(unsigned int))] || ((unsigned int *)&poller->wfds)[fd / (8 * sizeof(unsigned int))]) {
+ if (PHP_SAFE_FD_ISSET(fd, &poller->rfds) || PHP_SAFE_FD_ISSET(fd, &poller->wfds)) {
break;
}
- fd -= fd % (8 * sizeof(unsigned int));
}
poller->max_fd = fd;
}
@@ -772,23 +771,20 @@ static int php_cli_server_poller_iter_on_active(php_cli_server_poller *poller, v
}
#else
- php_socket_t fd = 0;
+ php_socket_t fd;
const php_socket_t max_fd = poller->max_fd;
- const unsigned int *pr = (unsigned int *)&poller->active.rfds,
- *pw = (unsigned int *)&poller->active.wfds,
- *e = pr + (max_fd + (8 * sizeof(unsigned int)) - 1) / (8 * sizeof(unsigned int));
- unsigned int mask;
- while (pr < e && fd <= max_fd) {
- for (mask = 1; mask; mask <<= 1, fd++) {
- int events = (*pr & mask ? POLLIN: 0) | (*pw & mask ? POLLOUT: 0);
- if (events) {
- if (SUCCESS != callback(opaque, fd, events)) {
- retval = FAILURE;
- }
- }
+
+ for (fd=0 ; fd<=max_fd ; fd++) {
+ if (PHP_SAFE_FD_ISSET(fd, &poller->active.rfds)) {
+ if (SUCCESS != callback(opaque, fd, POLLIN)) {
+ retval = FAILURE;
+ }
+ }
+ if (PHP_SAFE_FD_ISSET(fd, &poller->active.wfds)) {
+ if (SUCCESS != callback(opaque, fd, POLLOUT)) {
+ retval = FAILURE;
+ }
}
- pr++;
- pw++;
}
#endif
return retval;