[php-src] PR #26030: Fix socket_recvmsg() not recording the error on the Socket and warning for EAGAIN
| From: | lacatoire | Date: | Wed, 02 Dec 2026 09:36:47 +0000 |
| Subject: | [php-src] PR #26030: Fix socket_recvmsg() not recording the error on the Socket and warning for EAGAIN | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41360@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/26030
Author: lacatoire
socket_recvmsg() stores a failure only in the global last error and always warns, so
socket_last_error($socket) does not see it and a non-blocking socket warns for EAGAIN.
It now uses PHP_SOCKET_ERROR() like socket_sendmsg(),
socket_recv() and socket_recvfrom().
**To reproduce**
```php
<?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_last_error($socket));
```
Before:
```
Warning: socket_recvmsg(): Error in recvmsg [11]: Resource temporarily unavailable
bool(false)
int(11)
int(0)
```
After:
```
bool(false)
int(11)
int(11)
```