com php-src: Merge branch 'PHP-5.6': main/streams/plain_wrapp er.c
| From: | Anatol Belski | Date: | Mon, 29 Sep 2014 14:30:40 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6': main/streams/plain_wrapp er.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82006@lists.php.net to get a copy of this message | ||
Commit: 78e23758b7efa10d7f7957534c101e344c880545
Author: Anatol Belski <ab@php.net> Mon, 29 Sep 2014 16:30:40 +0200
Parents: f248b17e07d6746ed1057611cae5f2d11918fb4e 7e16bb263f959ddbb5ea9eac8326db9101dd5d5e
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=78e23758b7efa10d7f7957534c101e344c880545
Log:
Merge branch 'PHP-5.6'
* PHP-5.6:
updated NEWS
Fixed bug #51800 proc_open on Windows hangs forever
Conflicts:
main/streams/plain_wrapper.c
Bugs:
https://bugs.php.net/51800
Changed paths:
MM main/streams/plain_wrapper.c
Diff:
diff --cc main/streams/plain_wrapper.c
index 2b8dcc4,1969401..8f0b981
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@@ -348,7 -342,35 +348,35 @@@ static size_t php_stdiop_read(php_strea
assert(data != NULL);
if (data->fd >= 0) {
+ #ifdef PHP_WIN32
+ php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract;
+
+ if (self->is_pipe || self->is_process_pipe) {
+ HANDLE ph = (HANDLE)_get_osfhandle(data->fd);
+ int retry = 0;
+ DWORD avail_read = 0;
+
+ do {
+ /* Look ahead to get the available data amount to read. Do the same
+ as read() does, however not blocking forever. In case it failed,
+ no data will be read (better than block). */
+ if (!PeekNamedPipe(ph, NULL, 0, NULL, &avail_read, NULL)) {
+ break;
+ }
+ /* If there's nothing to read, wait in 100ms periods. */
+ if (0 == avail_read) {
+ usleep(100000);
+ }
+ } while (0 == avail_read && retry++ < 180);
+
+ /* Reduce the required data amount to what is available, otherwise read()
+ will block.*/
+ if (avail_read < count) {
+ count = avail_read;
+ }
+ }
+ #endif
- ret = read(data->fd, buf, count);
+ ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
if (ret == (size_t)-1 && errno == EINTR) {
/* Read was interrupted, retry once,