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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ PHP 8.7 UPGRADE NOTES
5. Changed Functions
========================================

- Sockets:
. socket_recvmsg() now records a failure on the Socket, so that
socket_last_error($socket) reports it, and no longer emits a warning for
EAGAIN on a non-blocking socket, as socket_recv() and socket_sendmsg() do.

- Standard:
. stream_select() no longer fails once a watched descriptor exceeds
FD_SETSIZE. The descriptor set now grows on demand on both POSIX (bitset)
Expand Down
4 changes: 1 addition & 3 deletions ext/sockets/sendrecvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ PHP_FUNCTION(socket_recvmsg)
}
RETVAL_LONG((zend_long)res);
} else {
SOCKETS_G(last_error) = errno;
php_error_docref(NULL, E_WARNING, "Error in recvmsg [%d]: %s",
errno, sockets_strerror(errno));
PHP_SOCKET_ERROR(php_sock, "Error in recvmsg", errno);
RETVAL_FALSE;
}

Expand Down
36 changes: 36 additions & 0 deletions ext/sockets/tests/socket_recvmsg_error_state.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
socket_recvmsg(): a failure is recorded on the Socket and EAGAIN does not warn
--EXTENSIONS--
sockets
--SKIPIF--
<?php
if (PHP_OS_FAMILY === 'Windows') {
die('skip not for Windows');
}
?>
--FILE--
<?php

$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, '127.0.0.1', 0);
socket_set_nonblock($socket);

$message = ['name' => [], 'buffer_size' => 64, 'controllen' => socket_cmsg_space(SOL_SOCKET, SCM_RIGHTS, 1)];
var_dump(socket_recvmsg($socket, $message, 0));
var_dump(socket_last_error() === SOCKET_EAGAIN);
var_dump(socket_last_error($socket) === SOCKET_EAGAIN);

$tcp = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$message = ['buffer_size' => 64, 'controllen' => socket_cmsg_space(SOL_SOCKET, SCM_RIGHTS, 1)];
var_dump(socket_recvmsg($tcp, $message, 0));
var_dump(socket_last_error($tcp) === SOCKET_ENOTCONN);

?>
--EXPECTF--
bool(false)
bool(true)
bool(true)

Warning: socket_recvmsg(): Error in recvmsg [%d]: %s in %s on line %d
bool(false)
bool(true)
Loading