summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Soria Parra <dsp@php.net>2008-08-26 16:06:36 +0000
committerDavid Soria Parra <dsp@php.net>2008-08-26 16:06:36 +0000
commit9f6848373421ea9ff81f41f3b5b6eaf0a797fa60 (patch)
treed587fe732e73f050512380db11b1ba1114eeea3b
parent421751d240734fffac73d3909bbc6cdc50e86d5f (diff)
downloadphp-git-9f6848373421ea9ff81f41f3b5b6eaf0a797fa60.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 9cc9563b5d..14700be268 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,7 @@ PHP NEWS
duplicate keys). (Dmitry)
- Fixed bug #43817 (opendir() fails on Windows directories with parent
directory unaccessible). (Dmitry)
+- Fixed bug #43782 (feof() does not detect timeout on socket). (David Soria Parra)
- Fixed bug #43008 (php://filter uris ignore url encoded filternames and can't
handle slashes). (Arnaud)
- Fixed bug #35980 (touch() works on files but not on directories). (Pierre)
diff --git a/main/streams/streams.c b/main/streams/streams.c
index b5e618a728..65421c299d 100755
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -642,7 +642,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 a7736878f4..0684d1ae76 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;
}
}