- SPL:
. Revert fix for bug #67064 (BC issues). (Bob)
-- Streams:
- . Expose so_reuseport and so_broadcast capability via socket context option
- assignment. (Daniel Lowrey)
-
- Zlib:
. Fixed bug #67724 (chained zlib filters silently fail with large amounts of
data). (Mike)
- Non-blocking read/write query behavior now optionally available in database
operations using the ext/pgsql extension.
-- Stream socket servers may now use SO_REUSEPORT in systems that support the
- option to bind on the same address/port in separate processes via a new
- "so_reuseport" socket context option.
-
-- UDP stream servers and clients may now enable SO_BROADCAST via a new
- "so_broadcast" socket context option.
-
========================================
3. Changes in SAPI modules
========================================
ftp->fd = php_network_connect_socket_to_host(host,
(unsigned short) (port ? port : 21), SOCK_STREAM,
- 0, &tv, NULL, NULL, NULL, 0, STREAM_SOCKOP_NONE TSRMLS_CC);
+ 0, &tv, NULL, NULL, NULL, 0 TSRMLS_CC);
if (ftp->fd == -1) {
goto bail;
}
* */
/* {{{ php_network_bind_socket_to_local_addr */
php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned port,
- int socktype, long sockopts, char **error_string, int *error_code
+ int socktype, char **error_string, int *error_code
TSRMLS_DC)
{
int num_addrs, n, err = 0;
php_socket_t sock;
struct sockaddr **sal, **psal, *sa;
socklen_t socklen;
- int sockoptval = 1;
num_addrs = php_network_getaddresses(host, socktype, &psal, error_string TSRMLS_CC);
/* attempt to bind */
#ifdef SO_REUSEADDR
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&sockoptval, sizeof(sockoptval));
-#endif
-#ifdef SO_REUSEPORT
- if (sockopts & STREAM_SOCKOP_SO_REUSEPORT) {
- setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char*)&sockoptval, sizeof(sockoptval));
- }
-#endif
-#ifdef SO_BROADCAST
- if (sockopts & STREAM_SOCKOP_SO_BROADCAST) {
- setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&sockoptval, sizeof(sockoptval));
+ {
+ int val = 1;
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&val, sizeof(val));
}
#endif
/* {{{ 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 bindport, long sockopts
+ int *error_code, char *bindto, unsigned short bindport
TSRMLS_DC)
{
int num_addrs, n, fatal = 0;
}
}
#endif
-
if (!local_address || bind(sock, local_address, local_address_len)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno));
}
*error_string = NULL;
}
-#ifdef SO_BROADCAST
- {
- int val = 1;
- if (sockopts & STREAM_SOCKOP_SO_BROADCAST) {
- setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&val, sizeof(val));
- }
- }
-#endif
n = php_network_connect_socket(sock, sa, socklen, asynchronous,
timeout ? &working_timeout : NULL,
error_string, error_code);
# define SOCK_RECV_ERR -1
#endif
-#define STREAM_SOCKOP_NONE 1 << 0
-#define STREAM_SOCKOP_SO_REUSEPORT 1 << 1
-#define STREAM_SOCKOP_SO_BROADCAST 1 << 2
-
-
/* uncomment this to debug poll(2) emulation on systems that have poll(2) */
/* #define PHP_USE_POLL_2_EMULATION 1 */
PHPAPI 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 bindport, long sockopts
+ int *error_code, char *bindto, unsigned short bindport
TSRMLS_DC);
PHPAPI int php_network_connect_socket(php_socket_t sockfd,
php_network_connect_socket((sock), (addr), (addrlen), 0, (timeout), NULL, NULL)
PHPAPI php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned port,
- int socktype, long sockopts, char **error_string, int *error_code
+ int socktype, char **error_string, int *error_code
TSRMLS_DC);
PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
{
char *host = NULL;
int portno, err;
- long sockopts = STREAM_SOCKOP_NONE;
- zval **tmpzval = NULL;
#ifdef AF_UNIX
if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {
return -1;
}
-#ifdef SO_REUSEPORT
- if (stream->context
- && php_stream_context_get_option(stream->context, "socket", "so_reuseport", &tmpzval) == SUCCESS
- && zend_is_true(*tmpzval)
- ) {
- sockopts |= STREAM_SOCKOP_SO_REUSEPORT;
- }
-#endif
-
-#ifdef SO_BROADCAST
- if (&php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */
- && stream->context
- && php_stream_context_get_option(stream->context, "socket", "so_broadcast", &tmpzval) == SUCCESS
- && zend_is_true(*tmpzval)
- ) {
- sockopts |= STREAM_SOCKOP_SO_BROADCAST;
- }
-#endif
-
sock->socket = php_network_bind_socket_to_local_addr(host, portno,
stream->ops == &php_stream_udp_socket_ops ? SOCK_DGRAM : SOCK_STREAM,
- sockopts,
xparam->want_errortext ? &xparam->outputs.error_text : NULL,
&err
TSRMLS_CC);
int err = 0;
int ret;
zval **tmpzval = NULL;
- long sockopts = STREAM_SOCKOP_NONE;
#ifdef AF_UNIX
if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {
bindto = parse_ip_address_ex(Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text TSRMLS_CC);
}
-#ifdef SO_BROADCAST
- if (&php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */
- && stream->context
- && php_stream_context_get_option(stream->context, "socket", "so_broadcast", &tmpzval) == SUCCESS
- && zend_is_true(*tmpzval)
- ) {
- sockopts |= STREAM_SOCKOP_SO_BROADCAST;
- }
-#endif
-
/* Note: the test here for php_stream_udp_socket_ops is important, because we
* want the default to be TCP sockets so that the openssl extension can
* re-use this code. */
xparam->want_errortext ? &xparam->outputs.error_text : NULL,
&err,
bindto,
- bindport,
- sockopts
+ bindport
TSRMLS_CC);
ret = sock->socket == -1 ? -1 : 0;