Report error from socket read on timeout

A timeout is not considered a transient error (at the socket layer),
and should return -1 rather than 0.
This commit is contained in:
Nikita Popov 2021-05-19 12:33:30 +02:00
parent 4c15dffe3a
commit 23c90dcdfb
2 changed files with 2 additions and 2 deletions

View file

@ -20,4 +20,4 @@ fclose($server);
?>
--EXPECT--
string(0) ""
bool(false)

View file

@ -163,7 +163,7 @@ static ssize_t php_sockop_read(php_stream *stream, char *buf, size_t count)
if (sock->is_blocked) {
php_sock_stream_wait_for_data(stream, sock);
if (sock->timeout_event)
return 0;
return -1;
}
nr_bytes = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0);