mirror of
https://github.com/php/php-src.git
synced 2026-03-26 01:02:25 +01:00
Avoids fclose() from complaining that stream_socket_pair() streams
have not been closed
This commit is contained in:
@@ -69,6 +69,11 @@ PHP_FUNCTION(stream_socket_pair)
|
||||
s1 = php_stream_sock_open_from_socket(pair[0], 0);
|
||||
s2 = php_stream_sock_open_from_socket(pair[1], 0);
|
||||
|
||||
/* set the __exposed flag.
|
||||
* php_stream_to_zval() does, add_next_index_resource() does not */
|
||||
php_stream_auto_cleanup(s1);
|
||||
php_stream_auto_cleanup(s2);
|
||||
|
||||
add_next_index_resource(return_value, php_stream_get_resource_id(s1));
|
||||
add_next_index_resource(return_value, php_stream_get_resource_id(s2));
|
||||
}
|
||||
|
||||
22
ext/standard/tests/streams/stream_socket_pair.phpt
Normal file
22
ext/standard/tests/streams/stream_socket_pair.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
stream_socket_pair()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip: non windows test");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, 0);
|
||||
var_dump($sockets);
|
||||
fwrite($sockets[0], b"foo");
|
||||
var_dump(fread($sockets[1], strlen(b"foo")));
|
||||
fclose($sockets[0]);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(2) {
|
||||
[0]=>
|
||||
resource(%d) of type (stream)
|
||||
[1]=>
|
||||
resource(%d) of type (stream)
|
||||
}
|
||||
string(3) "foo"
|
||||
Reference in New Issue
Block a user