Edit report at https://bugs.php.net/bug.php?id=61769&edit=1

 ID:                 61769
 Comment by:         a...@php.net
 Reported by:        mattfic...@php.net
 Summary:            Random failure of php_cli_server*phpt tests
 Status:             Open
 Type:               Bug
 Package:            Built-in web server
 PHP Version:        5.4.0
 Block user comment: N
 Private report:     N

 New Comment:

Matt, what i mean SO_REUSEADDR is defined on any Windows, see 
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx 
, as well as any other popular platform like gnu/bsd/solaris. And if it's 
defined, the piece of code with setsockopt is compiled and the option is set 
disregarding it's compiled with or without the wrapping #ifdef. Otherwise, if 
it were not defined, there were a compile error when you remove the wrapping 
#ifdef. That's why i wonder it changes something, because there is really no 
difference.


Previous Comments:
------------------------------------------------------------------------
[2012-04-19 23:26:33] mattfic...@php.net

Setting SO_REUSEADDR socket option will not only make sure all the tests pass 
every time, but also if user restarts the web server, it will make sure the web 
server can listen on that port when it restarts.

Most TCP servers set SO_REUSEADDR option.

This is a real problem on Windows and Linux and probably *BSD. Fixing it for 
those platforms is worth causing a minor compile problem for some weird os that 
doesn't have SO_REUSEADDR.

Alternatively, adding a sleep() call to the test after the web server exits 
should probably work, but it would make the test very slow (might have to wait 
60 seconds for each of 17 tests => 17 minutes).

------------------------------------------------------------------------
[2012-04-19 23:17:27] fel...@php.net

The test has been fixed in Git.

------------------------------------------------------------------------
[2012-04-19 14:54:39] a...@php.net

just came into my mind - may be it would have an effect if we just set a 
timeout at the top of the  php_cli_server_start() too? so the previous server 
had a chance to exit ...

------------------------------------------------------------------------
[2012-04-19 14:34:18] a...@php.net

Matt, unfortunately I can't reproduce the fails on my laptops, they're probably 
too slow. Nevertheless I'm not sure the patch does expected things. I've just 
debugged on win7 and ubuntu - SO_REUSEADDR is defined everywhere. MSDN even 
says it's available on all the versions. This means setsockopt should work as 
expected.

Besides that, removing that wrapping #ifdef could have impacts in some rare 
cases, i think, as SO_REUSEADDR is marked as a BSD macro, so despite it's 
luckily present on GNU, it might be absent on some POSIX-complaint only 
systems. Could you please explain why this fix is correct?

Also the php_cli_server_017.phpt was still failing for me, but that's just the 
unix/windows dir separator.

------------------------------------------------------------------------
[2012-04-19 14:15:26] a...@php.net

The following patch has been added/updated:

Patch Name: php_cli_server_017.diff
Revision:   1334844926
URL:        
https://bugs.php.net/patch-display.php?bug=61769&patch=php_cli_server_017.diff&revision=1334844926

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=61769


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61769&edit=1

Reply via email to