|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58199 spread_receive() should be able to wait forever
Submitted: 2008-05-23 07:06 UTC Modified: 2008-05-31 08:52 UTC
From: indeyets at gmail dot com Assigned:
Status: Closed Package: spread (PECL)
PHP Version: 5_2 CVS-2008-05-23 (dev) OS: irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: indeyets at gmail dot com
New email:
PHP Version: OS:


 [2008-05-23 07:06 UTC] indeyets at gmail dot com
spread_receive() has default value of 0 for "timeout" parameter which means, effectively, "check if there is anything on queue, but do not wait".

making timeout "positive" leads to some waiting-time in seconds.

wanted functionality: be able to wait for message without timeout. a common implementation for such cases is using "-1" value.

putting patch in "reproduce code" field

Reproduce code:
diff --git a/php_spread.c b/php_spread.c
index 69d6928..f325e29 100644
--- a/php_spread.c
+++ b/php_spread.c
@@ -590,12 +590,19 @@ PHP_FUNCTION(spread_receive) {
-       towait.tv_sec = (unsigned long)timeout;
-       towait.tv_usec = (unsigned long)(1000000.0 * (timeout - (double)towait.tv_sec));
        FD_SET(*mbox, &readfs);
-       if((ret = select(*mbox+1, &readfs, NULL, &readfs, &towait)) !=1 ) {
+       if (-1 == timeout) {
+               ret = select(*mbox+1, &readfs, NULL, &readfs, NULL);
+       } else {
+               towait.tv_sec = (unsigned long)timeout;
+               towait.tv_usec = (unsigned long)(1000000.0 * (timeout - (double)towait.tv_sec));
+               ret = select(*mbox+1, &readfs, NULL, &readfs, &towait);
+       }
+       if(1 != ret) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-31 08:52 UTC]
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 16 15:01:23 2021 UTC