php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61769
Patch 61769.patch.txt revision 2012-05-04 22:31 UTC by mattficken@php.net
Patch php_cli_server_017.diff revision 2012-04-19 14:15 UTC by ab@php.net
Patch php_cli_server.diff revision 2012-04-18 21:21 UTC by mattficken

Patch 61769.patch.txt for Built-in web server Bug #61769

Patch version 2012-05-04 22:31 UTC

Return to Bug #61769 | Download this patch
Patch Revisions:

Developer: mattficken@php.net

--- a/sapi/cli/tests/php_cli_server.inc	Fri May 04 05:02:15 2012
+++ b/sapi/cli/tests/php_cli_server.inc	Fri May 04 13:01:52 2012
@@ -1,3 +1,5 @@
 <?php
-define ("PHP_CLI_SERVER_ADDRESS", "localhost:8964");
+define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
+define ("PHP_CLI_SERVER_PORT", 8964);
+define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
 
@@ -34,2 +36,15 @@
 	}
+	
+	// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
+	//       it might not be listening yet...need to wait until fsockopen() call returns
+	$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT);
+	if ($fp) {
+		// server will report Unexpected EOF error (socket opened, closed without writing
+		// anything) but that can be ignored
+		fclose($fp);
+	} else {
+		// test will fail to connect if server doesn't start listening/accepting
+		// in the next few microseconds
+	}
+
 
@@ -42,3 +57,7 @@
 		);
-	usleep(50000);
+	// don't bother sleeping, server is already up
+	//usleep(50000);
+	// server can take a variable amount of time to be up, so just sleeping a guessed amount of time
+	// does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass
+	// sleeping doesn't work.
 }
--- a/sapi/cli/tests/php_cli_server_014.phpt	Fri May 04 05:02:15 2012
+++ b/sapi/cli/tests/php_cli_server_014.phpt	Fri May 04 14:43:50 2012
@@ -15,2 +15,6 @@
 
+// note: select() on Windows (& some other platforms) has historical issues with
+//       timeouts less than 1000 millis(0.5). it may be better to increase these
+//       timeouts to 1000 millis(1.0) (fsockopen eventually calls select()).
+//       see articles like: http://support.microsoft.com/kb/257821
 $fp = fsockopen($host, $port, $errno, $errstr, 0.5);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 13:01:30 2024 UTC