summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Soria Parra <dsp@php.net>2008-08-27 07:48:37 +0000
committerDavid Soria Parra <dsp@php.net>2008-08-27 07:48:37 +0000
commit8555d34ba51ecc02add759d4103818b9b152328e (patch)
tree97543ef567275e688650122e713c10f3f35a4be4
parent77e07a631a7d74ce15325c2ca7f23526f59fd5a0 (diff)
downloadphp-git-8555d34ba51ecc02add759d4103818b9b152328e.tar.gz
MFH: Fixed bug #43782 (feof() does not detect timeout on socket)
-rw-r--r--NEWS1
-rwxr-xr-xmain/streams/streams.c2
-rw-r--r--main/streams/xp_socket.c8
3 files changed, 8 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 301598f96e..5798e3e2a5 100644
--- a/NEWS
+++ b/NEWS
@@ -86,6 +86,7 @@ PHP NEWS
- Fixed bug #43993 (mb_substr_count() behaves differently to substr_count() with
overlapping needles). (Moriyoshi)
- Fixed bug #43941 (json_encode silently cuts non-UTF8 strings). (Stas)
+- Fixed bug #43782 (feof() does not detect timeout on socket). (David Soria Parra)
- Fixed bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines).
(Nuno)
- Fixed bug #42604 ("make test" fails with --with-config-file-scan-dir=path).
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 7349bb1480..c18c17e736 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -633,7 +633,7 @@ PHPAPI int _php_stream_eof(php_stream *stream TSRMLS_DC)
/* use the configured timeout when checking eof */
if (!stream->eof && PHP_STREAM_OPTION_RETURN_ERR ==
php_stream_set_option(stream, PHP_STREAM_OPTION_CHECK_LIVENESS,
- 0, NULL)) {
+ -1, NULL)) {
stream->eof = 1;
}
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 5e074a0ca0..e181feb94b 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -280,8 +280,12 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
if (sock->socket == -1) {
alive = 0;
- } else if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) {
- if (0 == recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EAGAIN) {
+ } else {
+ if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) {
+ if (0 == recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EAGAIN) {
+ alive = 0;
+ }
+ } else {
alive = 0;
}
}