Possibly also fixes #23220; warnings issued by fgets on ssl sockets.
int alive = 1;
int fd = sock->socket;
fd_set rfds;
- struct timeval tv = {0, 0};
+ struct timeval tv;
char buf;
+
+ if (sock->timeout.tv_sec == -1) {
+ tv.tv_sec = FG(default_socket_timeout);
+ } else {
+ tv = sock->timeout;
+ }
/* logic: if the select call indicates that there is data to
* be read, but a read returns 0 bytes of data, then the socket
if (stream->writepos - stream->readpos > 0)
return 0;
+ if (!stream->eof && php_stream_is(stream, PHP_STREAM_IS_SOCKET)) {
+ stream->eof = !_php_network_is_stream_alive(stream);
+ }
+
return stream->eof;
}