1--TEST--
2Bug #69521	Segfault in gc_collect_cycles()
3--FILE--
4<?php
5$serverUri = "tcp://127.0.0.1:64321";
6$sock = stream_socket_server($serverUri, $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN);
7
8$fp = stream_socket_client($serverUri, $errNumber, $errString, 5, STREAM_CLIENT_CONNECT);
9
10$written = 0;
11
12$data = "test";
13$written += fwrite($fp, substr($data, $written, 100));
14
15$link = stream_socket_accept($sock);
16fread($link, 1000);
17fwrite($link, "Sending bug 69521\n");
18fclose($link);
19
20while (!feof($fp))
21{
22	$read = $write = array($fp);
23
24	if ($written === strlen($data))
25		$write = array();
26
27	$changed = stream_select($read, $write, $except, 0, 500000);
28
29	if (!empty($read))
30		echo fread($fp, 4);
31}
32?>
33--EXPECT--
34Sending bug 69521
35