check the state of the queue before diving in to process it

darcs-hash:20080830095709-84dde-a64262c1b32e506cb2c43f8b4fb55ab88effc22f.gz
This commit is contained in:
Evan Prodromou 2008-08-30 05:57:09 -04:00
parent c46f152697
commit 0217a74f13
2 changed files with 16 additions and 2 deletions

View File

@ -616,4 +616,12 @@ class XMPPHP_XMLStream {
xml_set_element_handler($this->parser, 'startXML', 'endXML'); xml_set_element_handler($this->parser, 'startXML', 'endXML');
xml_set_character_data_handler($this->parser, 'charXML'); 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;
}
} }

View File

@ -53,9 +53,15 @@ class XmppQueueHandler extends QueueHandler {
} }
function idle() { 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 # Process the queue for a second
if ($this->conn->readyToProcess()) {
$this->log(LOG_DEBUG, 'Something in the incoming message queue; processing it.');
$this->conn->processTime(1); $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() { function finish() {