summaryrefslogtreecommitdiff
path: root/main/streams/plain_wrapper.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-07-23 11:57:02 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-07-25 10:42:10 +0200
commit1cbcf0f4f1e9a14b3fc76f6d3e53b567a9464fd4 (patch)
treec90f41f18aa20ea31ad32d2260a49c2ad56f890c /main/streams/plain_wrapper.c
parentdee243d475b088189862d30755aac7bb9cdd61b3 (diff)
downloadphp-git-1cbcf0f4f1e9a14b3fc76f6d3e53b567a9464fd4.tar.gz
Throw notice for plain wrapper fread/fwrite errors
Similar to what is done for socket read/write errors.
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r--main/streams/plain_wrapper.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 3c6a9afb28..bce58f7df2 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -351,6 +351,16 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
#else
ssize_t bytes_written = write(data->fd, buf, count);
#endif
+ if (bytes_written < 0) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN) {
+ return 0;
+ }
+ if (errno == EINTR) {
+ /* TODO: Should this be treated as a proper error or not? */
+ return bytes_written;
+ }
+ php_error_docref(NULL, E_NOTICE, "write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ }
return bytes_written;
} else {
@@ -415,11 +425,14 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
/* Not an error. */
ret = 0;
} else if (errno == EINTR) {
- /* An error, but not EOF */
- } else if (errno == EBADF) {
- /* TODO: Remove this special-case? */
+ /* TODO: Should this be treated as a proper error or not? */
} else {
- stream->eof = 1;
+ php_error_docref(NULL, E_NOTICE, "read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+
+ /* TODO: Remove this special-case? */
+ if (errno != EBADF) {
+ stream->eof = 1;
+ }
}
} else if (ret == 0) {
stream->eof = 1;