diff --git a/extlib/XMPPHP/XMLStream.php b/extlib/XMPPHP/XMLStream.php index 4de23ef7fb..62aa4de890 100644 --- a/extlib/XMPPHP/XMLStream.php +++ b/extlib/XMPPHP/XMLStream.php @@ -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; + } } diff --git a/scripts/xmppqueuehandler.php b/scripts/xmppqueuehandler.php index 040191c283..52db0eb59f 100755 --- a/scripts/xmppqueuehandler.php +++ b/scripts/xmppqueuehandler.php @@ -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() {