Skip to content

Commit 655e266

Browse files
committed
Merge branch 'PHP-7.0'
* PHP-7.0: update NEWS fix decrement_function regarding bug #70863 Fixed bug #70863 Incorect logic to increment_function for proxy objects no more dev ZEND_VERSION Add support for IPV6_V6ONLY on sockets Conflicts: Zend/zend.h
2 parents 69613a7 + 0cbf3af commit 655e266

6 files changed

Lines changed: 28 additions & 6 deletions

File tree

Zend/zend_operators.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,7 @@ ZEND_API int ZEND_FASTCALL increment_function(zval *op1) /* {{{ */
22772277
zval *val;
22782278

22792279
val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv);
2280-
Z_ADDREF_P(val);
2280+
Z_TRY_ADDREF_P(val);
22812281
increment_function(val);
22822282
Z_OBJ_HANDLER_P(op1, set)(op1, val);
22832283
zval_ptr_dtor(val);
@@ -2345,7 +2345,7 @@ ZEND_API int ZEND_FASTCALL decrement_function(zval *op1) /* {{{ */
23452345
zval *val;
23462346

23472347
val = Z_OBJ_HANDLER_P(op1, get)(op1, &rv);
2348-
Z_ADDREF_P(val);
2348+
Z_TRY_ADDREF_P(val);
23492349
decrement_function(val);
23502350
Z_OBJ_HANDLER_P(op1, set)(op1, val);
23512351
zval_ptr_dtor(val);

ext/sockets/sockets.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ static PHP_MINIT_FUNCTION(sockets)
716716
REGISTER_LONG_CONSTANT("IPV6_MULTICAST_LOOP", IPV6_MULTICAST_LOOP, CONST_CS | CONST_PERSISTENT);
717717
#endif
718718

719+
#ifdef IPV6_V6ONLY
720+
REGISTER_LONG_CONSTANT("IPV6_V6ONLY", IPV6_V6ONLY, CONST_CS | CONST_PERSISTENT);
721+
#endif
722+
719723
#ifndef WIN32
720724
# include "unix_socket_constants.h"
721725
#else

main/network.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,12 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
472472
#ifdef SO_REUSEADDR
473473
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&sockoptval, sizeof(sockoptval));
474474
#endif
475+
#ifdef IPV6_V6ONLY
476+
if (sockopts & STREAM_SOCKOP_IPV6_V6ONLY) {
477+
int ipv6_val = !!(sockopts & STREAM_SOCKOP_IPV6_V6ONLY_ENABLED);
478+
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6_val, sizeof(sockoptval));
479+
}
480+
#endif
475481
#ifdef SO_REUSEPORT
476482
if (sockopts & STREAM_SOCKOP_SO_REUSEPORT) {
477483
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char*)&sockoptval, sizeof(sockoptval));

main/php_network.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ typedef int php_socket_t;
106106
# define SOCK_RECV_ERR -1
107107
#endif
108108

109-
#define STREAM_SOCKOP_NONE 1 << 0
110-
#define STREAM_SOCKOP_SO_REUSEPORT 1 << 1
111-
#define STREAM_SOCKOP_SO_BROADCAST 1 << 2
109+
#define STREAM_SOCKOP_NONE (1 << 0)
110+
#define STREAM_SOCKOP_SO_REUSEPORT (1 << 1)
111+
#define STREAM_SOCKOP_SO_BROADCAST (1 << 2)
112+
#define STREAM_SOCKOP_IPV6_V6ONLY (1 << 3)
113+
#define STREAM_SOCKOP_IPV6_V6ONLY_ENABLED (1 << 4)
112114

113115

114116
/* uncomment this to debug poll(2) emulation on systems that have poll(2) */

main/streams/xp_socket.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,16 @@ static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *
635635
return -1;
636636
}
637637

638+
#ifdef IPV6_V6ONLY
639+
if (PHP_STREAM_CONTEXT(stream)
640+
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "ipv6_v6only")) != NULL
641+
&& Z_TYPE_P(tmpzval) != IS_NULL
642+
) {
643+
sockopts |= STREAM_SOCKOP_IPV6_V6ONLY;
644+
sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);
645+
}
646+
#endif
647+
638648
#ifdef SO_REUSEPORT
639649
if (PHP_STREAM_CONTEXT(stream)
640650
&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_reuseport")) != NULL

sapi/cli/tests/006.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ string(44) "Exception: Extension unknown does not exist
2525
"
2626
string(37) "Exception: Extension does not exist
2727
"
28-
string(%d) "Extension [ <persistent> extension #%d pcre version %d.%d.%d%a ] {
28+
string(%d) "Extension [ <persistent> extension #%d pcre version %s ] {
2929

3030
- INI {
3131
Entry [ pcre.backtrack_limit <ALL> ]

0 commit comments

Comments
 (0)