1--TEST-- 2Bug #70198 Checking liveness does not work as expected 3--SKIPIF-- 4<?php 5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 6?> 7--FILE-- 8<?php 9 10/* What is checked here is 11 - start a server and listen 12 - as soon as client connects, close connection and exit 13 - on the client side - sleep(1) and check feof() 14*/ 15 16$srv_addr = "tcp://127.0.0.1:8964"; 17$srv_fl = dirname(__FILE__) . "/bug70198_svr_" . md5(uniqid()) . ".php"; 18$srv_fl_cont = <<<SRV 19<?php 20\$socket = stream_socket_server('$srv_addr', \$errno, \$errstr); 21 22if (!\$socket) { 23 echo "\$errstr (\$errno)\\n"; 24} else { 25 if (\$conn = stream_socket_accept(\$socket, 3)) { 26 sleep(1); 27 /* just close the connection immediately after accepting, 28 the client side will need wait a bit longer to realize it.*/ 29 fclose(\$conn); 30 } 31 fclose(\$socket); 32} 33SRV; 34file_put_contents($srv_fl, $srv_fl_cont); 35$dummy0 = $dummy1 = array(); 36$srv_proc = proc_open(PHP_BINARY . " -n $srv_fl", $dummy0, $dummy1); 37 38$i = 0; 39/* wait a bit for the server startup */ 40sleep(1); 41$fp = stream_socket_client($srv_addr, $errno, $errstr, 2); 42if (!$fp) { 43 echo "$errstr ($errno)\n"; 44} else { 45 stream_set_blocking($fp, 0); 46 sleep(2); 47 while (!feof($fp)) { 48 ++$i; 49 } 50 fclose($fp); 51 var_dump($i); 52} 53 54proc_close($srv_proc); 55unlink($srv_fl); 56?> 57==DONE== 58--EXPECTF-- 59int(0) 60==DONE== 61 62