]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
check the state of the queue before diving in to process it
authorEvan Prodromou <evan@prodromou.name>
Sat, 30 Aug 2008 09:57:09 +0000 (05:57 -0400)
committerEvan Prodromou <evan@prodromou.name>
Sat, 30 Aug 2008 09:57:09 +0000 (05:57 -0400)
darcs-hash:20080830095709-84dde-a64262c1b32e506cb2c43f8b4fb55ab88effc22f.gz

extlib/XMPPHP/XMLStream.php
scripts/xmppqueuehandler.php

index 4de23ef7fba951c9635b11e7138d8a90a1358281..62aa4de890f534db9568b71cc15e9f102939378a 100644 (file)
@@ -616,4 +616,12 @@ class XMPPHP_XMLStream {
                xml_set_element_handler($this->parser, 'startXML', 'endXML');
                xml_set_character_data_handler($this->parser, 'charXML');
        }
+
+       public function readyToProcess() {
+               $read = array($this->socket);
+               $write = null;
+               $except = null;
+               $updated = @stream_select($read, $write, $except, 0);
+               return $updated !== false;
+       }
 }
index 040191c283cbbd93626b1082e0e0e28aeb9263fc..52db0eb59fe478eb46f8ef27bd7fb1b8ff0a6812 100755 (executable)
@@ -53,9 +53,15 @@ class XmppQueueHandler extends QueueHandler {
        }
 
        function idle() {
-               $this->log(LOG_DEBUG, 'Processing the incoming message queue.');
+           $this->log(LOG_DEBUG, 'Checking the incoming message queue.');
                # Process the queue for a second
-               $this->conn->processTime(1);
+               if ($this->conn->readyToProcess()) {
+                       $this->log(LOG_DEBUG, 'Something in the incoming message queue; processing it.');
+                       $this->conn->processTime(1);
+                       $this->log(LOG_DEBUG, 'Done processing incoming message queue.');
+               } else {
+                       $this->log(LOG_DEBUG, 'Nothing in the incoming message queue; skipping it.');
+               }
        }
 
        function finish() {