diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-08-29 16:03:52 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-08-29 16:03:52 -0400 |
commit | f5fe013657ced6920e3fe794a2a8d4122a85e377 (patch) | |
tree | 3495a0e116cbcbe052921634cd0c940c1920a3f2 /lib/queuehandler.php | |
parent | a0f726fb6cc42bd1390ab08164329f60e5333435 (diff) |
many jabber queue management changes
Added a method to QueueManager to let subclasses do stuff when idle.
Needed so that XMPP queue manager can service its message queue.
Cleaned up jabber_broadcast_message quite a bit. Use custom joins
instead of loop-and-query, should fix some problems with users who are
getting messages even after turning off notification. Only build $msg
and $entry once, and use the XMPPHP function for messages with a
payload, rather than rolling our own.
darcs-hash:20080829200352-84dde-427e4ca8c81d4222a36f78e7c580b611ff0bf765.gz
Diffstat (limited to 'lib/queuehandler.php')
-rw-r--r-- | lib/queuehandler.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/queuehandler.php b/lib/queuehandler.php index 747e7b493..470b595ba 100644 --- a/lib/queuehandler.php +++ b/lib/queuehandler.php @@ -57,7 +57,6 @@ class QueueHandler { function handle_queue() { $this->log(LOG_INFO, 'checking for queued notices'); - $cnt = 0; $transport = $this->transport(); do { $qi = Queue_item::top($transport); @@ -82,14 +81,23 @@ class QueueHandler { $this->log(LOG_WARNING, 'queue item for notice that does not exist'); } $qi->delete(); - $cnt++; + $this->idle(); } else { $this->clear_old_claims(); - sleep(10); + $start = microtime(); + $this->idle(); + $used = microtime() - $start; + if ($used < 5000000) { + usleep(5000000 - $used); + } } } while (true); } + function idle() { + return true; + } + function clear_old_claims() { $qi = new Queue_item(); $qi->transport = $this->transport(); |