From: daniel dot menard at bdsp dot tm dot fr Operating system: Win XP PHP version: 5.1.4 PHP Bug Type: Streams related Bug description: stream_socket_accept : big timeout values are not taken into account
Description: ------------ Time-out values passed to stream_socket_accept are not always taken into account has they should be. Values from 0 to 4294 seconds work fine, greater values do not (4295 is equivalent to 0 sec, 4296 to 1 sec and so on). >From current cvs source, it appears that the timeout parameter is multiplied and then cast to an unsigned long which results in an overflow for values greater than 4294: http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?view=annotate line 247 : /* prepare the timeout value for use */ conv = (unsigned long) (timeout * 1000000.0); tv.tv_sec = conv / 1000000; tv.tv_usec = conv % 1000000; Note: similar code can be found for stream_socket_client. Perhaps there are good reasons to not accept such timeout values. In this case, raising a 'bad parameter' exception and a note in the documentation would be better options than silently accept the overflow. Otherwise, a solution would be to test for big values: if (timeout>4294){tv.tv_sec=timeout; tv.tv_usec=0;} else { /* actual code */ } -- Edit bug report at http://bugs.php.net/?id=38096&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38096&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38096&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38096&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38096&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38096&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38096&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38096&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38096&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38096&r=support Expected behavior: http://bugs.php.net/fix.php?id=38096&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38096&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38096&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38096&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38096&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38096&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38096&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38096&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38096&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38096&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38096&r=mysqlcfg