From b25deaacea75f2e565a58ea14aca19627f5cfa93 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 21:24:02 -0800 Subject: queue daemon fixes: path fix for xmpp, suppress warning in memcached init --- lib/xmppmanager.php | 2 +- plugins/MemcachePlugin.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php index 9662e97d1..0839cda57 100644 --- a/lib/xmppmanager.php +++ b/lib/xmppmanager.php @@ -81,7 +81,7 @@ class XmppManager extends IoManager parent::start($master); $this->switchSite(); - require_once "lib/jabber.php"; + require_once INSTALLDIR . "/lib/jabber.php"; # Low priority; we don't want to receive messages diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index fbc2802f7..bc7fd9076 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -166,7 +166,7 @@ class MemcachePlugin extends Plugin if (is_array($this->servers)) { foreach ($this->servers as $server) { - list($host, $port) = explode(';', $server); + list($host, $port) = @explode(';', $server); if (empty($port)) { $port = 11211; } -- cgit v1.2.3-54-g00ecf From 4b839cfc53d1aa5aa64adb940e122efe1475c9e9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 21:35:47 -0800 Subject: fix for non-% memory soft limit --- lib/iomaster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iomaster.php b/lib/iomaster.php index aff5b145c..5d1071a39 100644 --- a/lib/iomaster.php +++ b/lib/iomaster.php @@ -231,7 +231,7 @@ class IoMaster return -1; } } else { - return $this->parseMemoryLimit($limit); + return $this->parseMemoryLimit($softLimit); } return $softLimit; } -- cgit v1.2.3-54-g00ecf From abd67452dad9c0e53427731d96de15428a99b086 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 22:12:19 -0800 Subject: go straight to the DB for inbox before insert --- classes/Inbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Inbox.php b/classes/Inbox.php index 83cfe8ef8..f3d4afca3 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -103,9 +103,9 @@ class Inbox extends Memcached_DataObject static function insertNotice($user_id, $notice_id) { - $inbox = Inbox::staticGet('user_id', $user_id); + $inbox = DB_DataObject::staticGet('inbox', 'user_id', $user_id); - if (empty($inbox) || $inbox->fake) { + if (empty($inbox)) { $inbox = Inbox::initialize($user_id); } -- cgit v1.2.3-54-g00ecf From 16742d0fde811256c386d1bae9768fcd939b9af8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 22:32:17 -0800 Subject: do since_id and max_id in inbox --- classes/Inbox.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/classes/Inbox.php b/classes/Inbox.php index f3d4afca3..312b4586b 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -153,8 +153,19 @@ class Inbox extends Memcached_DataObject $ids = unpack('N*', $inbox->notice_ids); - // XXX: handle since_id - // XXX: handle max_id + if (!empty($since_id)) { + $i = array_search($since_id, $ids); + if ($i !== false) { + $ids = array_slice($ids, 0, $i - 1); + } + } + + if (!empty($max_id)) { + $i = array_search($max_id, $ids); + if ($i !== false) { + $ids = array_slice($ids, $i - 1); + } + } $ids = array_slice($ids, $offset, $limit); -- cgit v1.2.3-54-g00ecf From 30e50439a32eaf7b68897c5b141c955f6906ad79 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 23:17:37 -0800 Subject: change double quotes to single quotes in numbered format string --- actions/all.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/all.php b/actions/all.php index efa4521e2..3eb185214 100644 --- a/actions/all.php +++ b/actions/all.php @@ -81,7 +81,7 @@ class AllAction extends ProfileAction function title() { if ($this->page > 1) { - return sprintf(_("%1$s and friends, page %2$d"), $this->user->nickname, $this->page); + return sprintf(_('%1$s and friends, page %2$d'), $this->user->nickname, $this->page); } else { return sprintf(_("%s and friends"), $this->user->nickname); } -- cgit v1.2.3-54-g00ecf From 28fafe803a82a0f5885655dfcad5e835163d3139 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 23:28:51 -0800 Subject: remove debugging statement for friends_timeline --- actions/apitimelinefriends.php | 1 - 1 file changed, 1 deletion(-) diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index ef58b103c..4e3827bae 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -72,7 +72,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction function prepare($args) { parent::prepare($args); - common_debug("api friends_timeline"); $this->user = $this->getTargetUser($this->arg('id')); if (empty($this->user)) { -- cgit v1.2.3-54-g00ecf From 8a7171fde610246e5820ee04441955bd8dd463bf Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 23:38:51 -0800 Subject: Don't barf on io loop if xmpp connection failed --- lib/xmppmanager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php index 0839cda57..dfff63a30 100644 --- a/lib/xmppmanager.php +++ b/lib/xmppmanager.php @@ -118,7 +118,11 @@ class XmppManager extends IoManager */ public function getSockets() { - return array($this->conn->getSocket()); + if ($this->conn) { + return array($this->conn->getSocket()); + } else { + return array(); + } } /** -- cgit v1.2.3-54-g00ecf From 2f32181c930afbbfad7986f84df908cac4ef182d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 00:19:25 -0800 Subject: Keep handler registration per-site to fix queue registration in mixed config environment --- lib/stompqueuemanager.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php index 3090e0bfb..a7d735d1c 100644 --- a/lib/stompqueuemanager.php +++ b/lib/stompqueuemanager.php @@ -66,10 +66,57 @@ class StompQueueManager extends QueueManager * * @fixme possibly actually do subscription here to save another * loop over all sites later? + * @fixme possibly don't assume it's the current site */ public function addSite($server) { $this->sites[] = $server; + $this->initialize(); + } + + + /** + * Instantiate the appropriate QueueHandler class for the given queue. + * + * @param string $queue + * @return mixed QueueHandler or null + */ + function getHandler($queue) + { + $handlers = $this->handlers[common_config('site', 'server')]; + if (isset($handlers[$queue])) { + $class = $handlers[$queue]; + if (class_exists($class)) { + return new $class(); + } else { + common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'"); + } + } else { + common_log(LOG_ERR, "Requested handler for unkown queue '$queue'"); + } + return null; + } + + /** + * Get a list of all registered queue transport names. + * + * @return array of strings + */ + function getQueues() + { + return array_keys($this->handlers[common_config('site', 'server')]); + } + + /** + * Register a queue transport name and handler class for your plugin. + * Only registered transports will be reliably picked up! + * + * @param string $transport + * @param string $class + */ + public function connect($transport, $class) + { + $this->handlers[common_config('site', 'server')][$transport] = $class; } /** -- cgit v1.2.3-54-g00ecf From 5783874cc20ab0f856ea6b3f41510a303a8bd3a2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 14:07:24 -0800 Subject: Clean up host/port separation in memcached plugin -- use : not ; as separator and clean up some warnings --- plugins/MemcachePlugin.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index bc7fd9076..5214ab9c8 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -165,20 +165,18 @@ class MemcachePlugin extends Plugin $this->_conn = new Memcache(); if (is_array($this->servers)) { - foreach ($this->servers as $server) { - list($host, $port) = @explode(';', $server); - if (empty($port)) { - $port = 11211; - } - - $this->_conn->addServer($host, $port, $this->persistent); - } + $servers = $this->servers; } else { - $this->_conn->addServer($this->servers, $this->persistent); - list($host, $port) = explode(';', $this->servers); - if (empty($port)) { + $servers = array($this->servers); + } + foreach ($servers as $server) { + if (strpos($server, ':') !== false) { + list($host, $port) = explode(':', $server); + } else { + $host = $server; $port = 11211; } + $this->_conn->addServer($host, $port, $this->persistent); } -- cgit v1.2.3-54-g00ecf From 58bc33850ab615f21b4364aac8b8b7f74a95111d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 15:32:37 -0800 Subject: temporary --skip-xmpp flag on queuedaemon.php, allows to run queue daemons but skip subscription to xmpp-based queues (still working on making these behave gracefully when server is down) --- lib/queuemanager.php | 2 +- scripts/queuedaemon.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/queuemanager.php b/lib/queuemanager.php index a98c0efff..b98e57a1f 100644 --- a/lib/queuemanager.php +++ b/lib/queuemanager.php @@ -157,7 +157,7 @@ abstract class QueueManager extends IoManager } // XMPP output handlers... - if (common_config('xmpp', 'enabled')) { + if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) { $this->connect('jabber', 'JabberQueueHandler'); $this->connect('public', 'PublicQueueHandler'); diff --git a/scripts/queuedaemon.php b/scripts/queuedaemon.php index 8ef364fe7..f8bade39d 100755 --- a/scripts/queuedaemon.php +++ b/scripts/queuedaemon.php @@ -21,7 +21,7 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); $shortoptions = 'fi:at:'; -$longoptions = array('id=', 'foreground', 'all', 'threads='); +$longoptions = array('id=', 'foreground', 'all', 'threads=', 'skip-xmpp'); /** * Attempts to get a count of the processors available on the current system @@ -260,6 +260,10 @@ if (!$threads) { $daemonize = !(have_option('f') || have_option('--foreground')); $all = have_option('a') || have_option('--all'); +if (have_option('--skip-xmpp')) { + define('XMPP_EMERGENCY_FLAG', true); +} + $daemon = new QueueDaemon($id, $daemonize, $threads, $all); $daemon->runOnce(); -- cgit v1.2.3-54-g00ecf From 038287c1ffb71207f8028014f20005483364956d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 14 Jan 2010 17:14:41 -0800 Subject: fix for --skip-xmpp hack -- forgot to do it on the ping & confirm handlers --- lib/iomaster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iomaster.php b/lib/iomaster.php index 5d1071a39..ce77b53b2 100644 --- a/lib/iomaster.php +++ b/lib/iomaster.php @@ -70,7 +70,7 @@ class IoMaster $classes = array(); if (Event::handle('StartIoManagerClasses', array(&$classes))) { $classes[] = 'QueueManager'; - if (common_config('xmpp', 'enabled')) { + if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) { $classes[] = 'XmppManager'; // handles pings/reconnects $classes[] = 'XmppConfirmManager'; // polls for outgoing confirmations } -- cgit v1.2.3-54-g00ecf