]> granicus.if.org Git - php/commitdiff
Revert "Add SO_REUSEPORT + SO_BROADCAST support via socket stream context option"
authorFerenc Kovacs <tyrael@php.net>
Wed, 6 Aug 2014 18:33:48 +0000 (20:33 +0200)
committerFerenc Kovacs <tyrael@php.net>
Wed, 6 Aug 2014 18:33:48 +0000 (20:33 +0200)
This reverts commit a51bf0cadf7862d10b2cc19cae2c991d24d670b1.

NEWS
UPGRADING
ext/ftp/ftp.c
main/network.c
main/php_network.h
main/streams/xp_socket.c

diff --git a/NEWS b/NEWS
index 1d38b992c9331c05044cea017bf0ea33f4948e7a..2158d4637532474744b92fcb918dc04501340d66 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,10 +21,6 @@ PHP                                                                        NEWS
 - 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)
index 908e819517b09420625012608c52f9dd5f31a074..7a174c47c2a034ac3718cf364cde66569d72b0d7 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -151,13 +151,6 @@ PHP 5.6 UPGRADE NOTES
 - 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
 ========================================
index d05f0eec71c41c858503f18ee3e3e15131d5a732..558463b845d457f68c509920c7774568960884e7 100644 (file)
@@ -136,7 +136,7 @@ ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC)
 
        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;
        }
index 39f5a22f4838b7fcd6aef21447572b867aedda9b..fc2a94badd5b81d7b25bed222c7fafb3cb6c15de 100644 (file)
@@ -416,14 +416,13 @@ static inline void sub_times(struct timeval a, struct timeval b, struct timeval
  * */
 /* {{{ 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);
 
@@ -465,16 +464,9 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
                        /* 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
 
@@ -770,7 +762,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
 /* {{{ 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;
@@ -872,7 +864,6 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
                                        }
                                }
 #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));
                                }
@@ -887,14 +878,6 @@ skip_bind:
                                *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);
index 95299e63da485287385f358c5fa6a6833de42a68..d69bba308addacb1812eeab37ddbe329e3909dad 100644 (file)
@@ -105,11 +105,6 @@ typedef int php_socket_t;
 # 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 */
 
@@ -234,7 +229,7 @@ PHPAPI void php_network_freeaddresses(struct sockaddr **sal);
 
 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,
@@ -249,7 +244,7 @@ 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,
index c7b5a7098d31e1a72a42b87df2f784c7dadee29f..a6dc1159624cc8a39550d4fce8d03b2e6ab46032 100644 (file)
@@ -570,8 +570,6 @@ static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *
 {
        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) {
@@ -601,28 +599,8 @@ static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *
                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);
@@ -642,7 +620,6 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
        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) {
@@ -688,16 +665,6 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
                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. */
@@ -709,8 +676,7 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
                        xparam->want_errortext ? &xparam->outputs.error_text : NULL,
                        &err,
                        bindto,
-                       bindport,
-                       sockopts
+                       bindport
                        TSRMLS_CC);
        
        ret = sock->socket == -1 ? -1 : 0;