summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-08-27 10:23:36 -0400
committerEvan Prodromou <evan@prodromou.name>2008-08-27 10:23:36 -0400
commitf3dc863d8fd7ad7da3a8539dabb5b8d5ba5e84b4 (patch)
tree2e0c717cf55598d6d0f3d3d9006d1335d26ffcd6 /scripts
parent9bdc7f8ec7abb53990b9360ccbdf5d38915c26de (diff)
don't do too many broadcasts or confirms before checking the message queue
darcs-hash:20080827142336-84dde-2bec2149d86900fd0291f8c00f85aa756842bbe1.gz
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/xmppdaemon.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 8b5c727b6..da1638011 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -53,6 +53,9 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
define('CLAIM_TIMEOUT', 100000);
+define('MAX_BROADCAST_COUNT', 20);
+define('MAX_CONFIRM_COUNT', 20);
+
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/jabber.php');
@@ -101,7 +104,7 @@ class XMPPDaemon {
$this->conn->addEventHandler('session_start', 'handle_session_start', $this);
while(!$this->conn->isDisconnected()) {
- $this->conn->processTime(10);
+ $this->conn->processTime(5);
$this->broadcast_queue();
$this->confirmation_queue();
}
@@ -339,6 +342,7 @@ class XMPPDaemon {
function broadcast_queue() {
$this->clear_old_claims();
$this->log(LOG_INFO, 'checking for queued notices');
+ $cnt = 0;
do {
$qi = $this->top_queue_item();
if ($qi) {
@@ -362,8 +366,9 @@ class XMPPDaemon {
$this->log(LOG_WARNING, 'queue item for notice that does not exist');
}
$qi->delete();
+ $cnt++;
}
- } while ($qi);
+ } while ($qi && $cnt < MAX_BROADCAST_COUNT);
}
function clear_old_claims() {
@@ -381,6 +386,7 @@ class XMPPDaemon {
function confirmation_queue() {
# $this->clear_old_confirm_claims();
$this->log(LOG_INFO, 'checking for queued confirmations');
+ $cnt = 0;
do {
$confirm = $this->next_confirm();
if ($confirm) {
@@ -409,8 +415,9 @@ class XMPPDaemon {
continue;
}
}
+ $cnt++;
}
- } while ($confirm);
+ } while ($confirm && $cnt < MAX_CONFIRM_COUNT);
}
function next_confirm() {