mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Fixed bug #72853 (stream_set_blocking doesn't work)
Implemented PHP_STREAM_OPTION_META_DATA_API for plain_wrappers
This commit is contained in:
parent
9e00ad2b09
commit
abe00908af
3
NEWS
3
NEWS
@ -2,6 +2,9 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2016, PHP 5.6.26
|
||||
|
||||
- Streams:
|
||||
. Fixed bug #72853 (stream_set_blocking doesn't work). (Laruence)
|
||||
|
||||
- FTP:
|
||||
. Fixed bug #70195 (Cannot upload file using ftp_put to FTPES with
|
||||
require_ssl_reuse). (Benedict Singer)
|
||||
|
59
ext/standard/tests/streams/bug72853.phpt
Normal file
59
ext/standard/tests/streams/bug72853.phpt
Normal file
@ -0,0 +1,59 @@
|
||||
--TEST--
|
||||
Bug #72853 (stream_set_blocking doesn't work)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
|
||||
die('skip not for windows');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$descs = array(
|
||||
0 => array('pipe', 'r'), // stdin
|
||||
1 => array('pipe', 'w'), // stdout
|
||||
);
|
||||
|
||||
$p = proc_open("ls", $descs, $pipes, '.', NULL, NULL);
|
||||
|
||||
stream_set_blocking($pipes[1], false);
|
||||
var_dump(stream_get_meta_data($pipes[1]));
|
||||
stream_set_blocking($pipes[1], true);
|
||||
while ($outs = fgets($pipes[1], 1024)) {
|
||||
}
|
||||
var_dump(stream_get_meta_data($pipes[1]));
|
||||
proc_close($p);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(7) {
|
||||
["timed_out"]=>
|
||||
bool(false)
|
||||
["blocked"]=>
|
||||
bool(false)
|
||||
["eof"]=>
|
||||
bool(false)
|
||||
["stream_type"]=>
|
||||
string(5) "STDIO"
|
||||
["mode"]=>
|
||||
string(1) "r"
|
||||
["unread_bytes"]=>
|
||||
int(0)
|
||||
["seekable"]=>
|
||||
bool(false)
|
||||
}
|
||||
array(7) {
|
||||
["timed_out"]=>
|
||||
bool(false)
|
||||
["blocked"]=>
|
||||
bool(true)
|
||||
["eof"]=>
|
||||
bool(true)
|
||||
["stream_type"]=>
|
||||
string(5) "STDIO"
|
||||
["mode"]=>
|
||||
string(1) "r"
|
||||
["unread_bytes"]=>
|
||||
int(0)
|
||||
["seekable"]=>
|
||||
bool(false)
|
||||
}
|
@ -818,7 +818,19 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
|
||||
return ftruncate(fd, new_size) == 0 ? PHP_STREAM_OPTION_RETURN_OK : PHP_STREAM_OPTION_RETURN_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
case PHP_STREAM_OPTION_META_DATA_API:
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
#ifdef O_NONBLOCK
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
|
||||
add_assoc_bool((zval*)ptrparam, "timed_out", 0);
|
||||
add_assoc_bool((zval*)ptrparam, "blocked", (flags & O_NONBLOCK)? 0 : 1);
|
||||
add_assoc_bool((zval*)ptrparam, "eof", stream->eof);
|
||||
|
||||
return PHP_STREAM_OPTION_RETURN_OK;
|
||||
#endif
|
||||
return -1;
|
||||
default:
|
||||
return PHP_STREAM_OPTION_RETURN_NOTIMPL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user