Bug #63099 [NEW]: stream_socket_accept does not respect float seconds
| From: | prggmr at gmail dot com | Date: | Sun, 16 Sep 2012 14:43:41 +0000 |
| Subject: | Bug #63099 [NEW]: stream_socket_accept does not respect float seconds | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-173483@lists.php.net to get a copy of this message | ||
From: prggmr at gmail dot com
Operating system: Mac OSX/Unix
PHP version: 5.4.7
Package: Streams related
Bug Type: Bug
Bug description:stream_socket_accept does not respect float seconds
Description:
------------
---
From manual page:
http://www.php.net/function.stream-socket-accept#refsect1-
function.stream-socket-accept-description
---
stream_socket_accept does not properly timeout given a floated time under 0
seconds.
The documentation states it does accept a float and should be given in
seconds,
so a timeout such as .0010 should be valid and used.
Test script:
---------------
/**
* Stream socket accept does not accept floats as documented
*/
function milliseconds(/* ... */) {
return round(microtime(true) * 1000);
}
$socket = stream_socket_server('tcp://127.0.0.1:5000', $errno, $errstr);
stream_set_blocking($socket, 0);
echo "START TIME".PHP_EOL;
echo milliseconds().PHP_EOL;
while(false !== $connect = @stream_socket_accept($socket, .0010)) {
}
echo "END TIME".PHP_EOL;
echo milliseconds().PHP_EOL;
echo "START TIME".PHP_EOL;
echo milliseconds().PHP_EOL;
usleep(10 * 1000);
echo "END TIME".PHP_EOL;
echo milliseconds().PHP_EOL;
Expected result:
----------------
START TIME
1347806197759
END TIME
1347806197769
START TIME
1347806197760
END TIME
1347806197770
Actual result:
--------------
START TIME
1347806197759
END TIME
1347806197760
START TIME
1347806197760
END TIME
1347806197770
--
Edit bug report at https://bugs.php.net/bug.php?id=63099&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63099&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63099&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63099&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63099&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=63099&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=63099&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63099&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63099&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63099&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63099&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63099&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63099&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63099&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63099&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63099&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63099&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63099&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63099&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63099&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63099&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63099&r=mysqlcfg