X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fqueuehandler.php;h=237df9a7b818f948a4ca1002bd2d88daa72e91a7;hb=4520daac3e2e58c6bd0bdc93cef964ee22be9f37;hp=3115ea38d2a470334ee5dd8783d606fd383e13b8;hpb=d5f83d92521dbf838b1fc1fad2716efc3122c6b7;p=quix0rs-gnu-social.git diff --git a/lib/queuehandler.php b/lib/queuehandler.php index 3115ea38d2..237df9a7b8 100644 --- a/lib/queuehandler.php +++ b/lib/queuehandler.php @@ -19,7 +19,11 @@ define('CLAIM_TIMEOUT', 1200); -class QueueHandler { +if (!defined('LACONICA')) { exit(1); } + +require_once(INSTALLDIR.'/lib/daemon.php'); + +class QueueHandler extends Daemon { var $_id = 'generic'; @@ -32,6 +36,10 @@ class QueueHandler { function class_name() { return ucfirst($this->transport()) . 'Handler'; } + + function name() { + return strtolower($this->class_name().'.'.$this->get_id()); + } function get_id() { return $this->_id; @@ -55,7 +63,10 @@ class QueueHandler { return true; } - function handle_queue() { + function run() { + if (!$this->start()) { + return false; + } $this->log(LOG_INFO, 'checking for queued notices'); $transport = $this->transport(); do { @@ -76,17 +87,25 @@ class QueueHandler { continue; } $this->log(LOG_INFO, 'finished broadcasting notice ID = ' . $notice->id); + $notice->free(); + unset($notice); $notice = NULL; } else { $this->log(LOG_WARNING, 'queue item for notice that does not exist'); } $qi->delete(); + $qi->free(); + unset($qi); $this->idle(0); } else { $this->clear_old_claims(); $this->idle(5); } } while (true); + if (!$this->finish()) { + return false; + } + return true; } function idle($timeout=0) { @@ -100,6 +119,8 @@ class QueueHandler { $qi->transport = $this->transport(); $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT); $qi->update(DB_DATAOBJECT_WHEREADD_ONLY); + $qi->free(); + unset($qi); } function log($level, $msg) {