1
0
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:
Arnaud Le Blanc
2008-11-04 16:45:42 +00:00
parent 9cb71e98b7
commit 0bb5310a63
2 changed files with 27 additions and 0 deletions

View File

@@ -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));
}

View 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"