Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ rewritten to comply with these rules.

1. The length of constant string literals should be calculated via ``strlen()``
instead of using ``sizeof()-1`` as it is clearer and any modern compiler
will optimize it away. Legacy usages of the latter style exists within the
will optimize it away. Legacy usages of the latter style exist within the
codebase but should not be refactored, unless larger refactoring around that
code is taking place.

Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,8 @@ PHP 8.6 UPGRADE NOTES
. Arguments are now passed more efficiently to known constructors (e.g. when
using new self()).

- DOM:
. Made splitText() faster and consume less memory.

- JSON:
. Improve performance of encoding arrays and objects.
11 changes: 6 additions & 5 deletions ext/dom/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,18 @@ PHP_METHOD(DOMText, splitText)
first = xmlUTF8Strndup(cur, (int)offset);
second = xmlUTF8Strsub(cur, (int)offset, (int)(length - offset));

xmlNodeSetContent(node, first);
nnode = xmlNewDocText(node->doc, second);

xmlFree(first);
xmlFree(second);
xmlNodeSetContent(node, NULL);
node->content = first;
nnode = xmlNewDocText(node->doc, NULL);

if (nnode == NULL) {
xmlFree(second);
php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true);
RETURN_THROWS();
}

nnode->content = second;

if (node->parent != NULL) {
nnode->type = XML_ELEMENT_NODE;
xmlAddNextSibling(node, nnode);
Expand Down
4 changes: 4 additions & 0 deletions ext/sockets/sockets.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,15 @@
* @cvalue TCP_KEEPIDLE
*/
const TCP_KEEPIDLE = UNKNOWN;
#endif
#ifdef TCP_KEEPINTVL
/**
* @var int
* @cvalue TCP_KEEPINTVL
*/
const TCP_KEEPINTVL = UNKNOWN;
#endif
#ifdef TCP_KEEPCNT
/**
* @var int
* @cvalue TCP_KEEPCNT
Expand Down
6 changes: 5 additions & 1 deletion ext/sockets/sockets_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions ext/sockets/tests/socket_tcp_keepalive.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--TEST--
Test SO_KEEPALIVE and TCP keepalive constants
--EXTENSIONS--
sockets
--SKIPIF--
<?php
if (!defined('TCP_KEEPIDLE') && !defined('TCP_KEEPALIVE')) {
die('skip TCP_KEEPIDLE/TCP_KEEPALIVE not available');
}
if (!defined('TCP_KEEPINTVL')) {
die('skip TCP_KEEPINTVL not available');
}
if (!defined('TCP_KEEPCNT')) {
die('skip TCP_KEEPCNT not available');
}
?>
--FILE--
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {
die("socket failed");
}

socket_set_option($socket, SOL_SOCKET, SO_KEEPALIVE, 1);
$keepalive = socket_get_option($socket, SOL_SOCKET, SO_KEEPALIVE);
echo "SO_KEEPALIVE: " . ($keepalive ? "enabled" : "disabled") . "\n";

if (defined('TCP_KEEPIDLE')) {
socket_set_option($socket, SOL_TCP, TCP_KEEPIDLE, 60);
$idle = socket_get_option($socket, SOL_TCP, TCP_KEEPIDLE);
echo "TCP_KEEPIDLE: $idle\n";
} else {
socket_set_option($socket, SOL_TCP, TCP_KEEPALIVE, 60);
$idle = socket_get_option($socket, SOL_TCP, TCP_KEEPALIVE);
echo "TCP_KEEPIDLE: $idle\n";
}

socket_set_option($socket, SOL_TCP, TCP_KEEPINTVL, 10);
$intvl = socket_get_option($socket, SOL_TCP, TCP_KEEPINTVL);
echo "TCP_KEEPINTVL: $intvl\n";

socket_set_option($socket, SOL_TCP, TCP_KEEPCNT, 5);
$cnt = socket_get_option($socket, SOL_TCP, TCP_KEEPCNT);
echo "TCP_KEEPCNT: $cnt\n";

socket_close($socket);
?>
--EXPECT--
SO_KEEPALIVE: enabled
TCP_KEEPIDLE: 60
TCP_KEEPINTVL: 10
TCP_KEEPCNT: 5