]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
slightly better timing
authorEvan Prodromou <evan@controlyourself.ca>
Thu, 9 Jul 2009 15:40:01 +0000 (11:40 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Thu, 9 Jul 2009 15:40:01 +0000 (11:40 -0400)
lib/stompqueuemanager.php
lib/xmppqueuehandler.php

index 4cefba1132d5f99cdd8739de9cb2e084c9451d0b..4d89806f8d8034136af17eb3a39115e16fd6d7a0 100644 (file)
@@ -117,9 +117,12 @@ class StompQueueManager
                 }
 
                 unset($frame);
-            }
 
-            $handler->idle(0);
+                $handler->idle(QUEUE_HANDLER_HIT_IDLE);
+
+            } else {
+                $handler->idle(QUEUE_HANDLER_MISS_IDLE);
+            }
         }
 
         $this->con->unsubscribe($this->_queueName($queue));
index 9b1a6989e2d1f25fae2698dc9cd833d3edba8178..cbcfe5e1c657f309ec7ba14bfd4cdd514d710598 100644 (file)
@@ -21,6 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
 
 require_once(INSTALLDIR.'/lib/queuehandler.php');
 
+define('PING_INTERVAL', 120);
+
 /**
  * Common superclass for all XMPP-using queue handlers. They all need to
  * service their message queues on idle, and forward any incoming messages
@@ -31,6 +33,7 @@ require_once(INSTALLDIR.'/lib/queuehandler.php');
 class XmppQueueHandler extends QueueHandler
 {
     var $pingid = 0;
+    var $lastping = null;
 
     function start()
     {
@@ -64,7 +67,11 @@ class XmppQueueHandler extends QueueHandler
             if ($this->conn) {
                 $this->log(LOG_DEBUG, "Servicing the XMPP queue.");
                 $this->conn->processTime($timeout);
-                $this->sendPing();
+                $now = time();
+                if (empty($this->lastping) || $now - $this->lastping > PING_INTERVAL) {
+                    $this->sendPing();
+                    $this->lastping = $now;
+                }
             }
         } catch (XMPPHP_Exception $e) {
             $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());