summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@controlyourself.ca>2009-07-24 15:06:07 +0000
committerSarven Capadisli <csarven@controlyourself.ca>2009-07-24 15:06:07 +0000
commitbb2186527a138086efbffc56452bd29a9f06e643 (patch)
tree823b2aeff5b47de5ee1406658b0a6528db4e26d8
parent8d2aeb7082cca4a19b3700b62cae77cf50260217 (diff)
parenta3a5d23c54bfd2207728a957f370fc83ebfc4c65 (diff)
Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x
-rw-r--r--classes/Fave.php2
-rw-r--r--classes/Notice.php3
-rw-r--r--classes/User.php2
-rw-r--r--lib/dbqueuemanager.php12
-rwxr-xr-xscripts/twitterstatusfetcher.php2
5 files changed, 13 insertions, 8 deletions
diff --git a/classes/Fave.php b/classes/Fave.php
index 4b28d06b4..11e876ff1 100644
--- a/classes/Fave.php
+++ b/classes/Fave.php
@@ -59,7 +59,7 @@ class Fave extends Memcached_DataObject
$qry = 'SELECT fave.* FROM fave ';
$qry .= 'INNER JOIN notice ON fave.notice_id = notice.id ';
$qry .= 'WHERE fave.user_id = ' . $user_id . ' ';
- $qry .= 'AND notice.is_local != ' . NOTICE_GATEWAY . ' ';
+ $qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';
}
if ($since_id != 0) {
diff --git a/classes/Notice.php b/classes/Notice.php
index 7f002d838..c2770edbe 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -32,7 +32,6 @@ define('NOTICE_CACHE_WINDOW', 61);
define('NOTICE_LOCAL_PUBLIC', 1);
define('NOTICE_REMOTE_OMB', 0);
define('NOTICE_LOCAL_NONPUBLIC', -1);
-define('NOTICE_GATEWAY', -2);
define('MAX_BOXCARS', 128);
@@ -63,6 +62,8 @@ class Notice extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+ const GATEWAY = -2;
+
function getProfile()
{
return Profile::staticGet('id', $this->profile_id);
diff --git a/classes/User.php b/classes/User.php
index 6c1f149e4..bea47a3b0 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -443,7 +443,7 @@ class User extends Memcached_DataObject
'SELECT notice.* ' .
'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
'WHERE subscription.subscriber = %d ' .
- 'AND notice.is_local != ' . NOTICE_GATEWAY;
+ 'AND notice.is_local != ' . Notice::GATEWAY;
return Notice::getStream(sprintf($qry, $this->id),
'user:notices_with_friends:' . $this->id,
$offset, $limit, $since_id, $before_id,
diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php
index 1df5af6c1..19aa9f3ae 100644
--- a/lib/dbqueuemanager.php
+++ b/lib/dbqueuemanager.php
@@ -22,7 +22,6 @@
* @category QueueManager
* @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca>
- * @author Sarven Capadisli <csarven@controlyourself.ca>
* @copyright 2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
@@ -86,10 +85,14 @@ class DBQueueManager extends QueueManager
$start = time();
$result = null;
+ $sleeptime = 1;
+
do {
$qi = Queue_item::top($queue);
if (empty($qi)) {
- sleep(1);
+ $this->_log(LOG_DEBUG, "No new queue items, sleeping $sleeptime seconds.");
+ sleep($sleeptime);
+ $sleeptime *= 2;
} else {
$notice = Notice::staticGet('id', $qi->notice_id);
if (!empty($notice)) {
@@ -100,6 +103,7 @@ class DBQueueManager extends QueueManager
$qi->free();
$qi = null;
}
+ $sleeptime = 1;
}
} while (empty($result) && (is_null($timeout) || (time() - $start) < $timeout));
@@ -120,7 +124,7 @@ class DBQueueManager extends QueueManager
} else {
if (empty($qi->claimed)) {
$this->_log(LOG_WARNING, 'Reluctantly releasing unclaimed queue item '.
- 'for '.$notice->id.', queue '.$queue);
+ 'for '.$notice->id.', queue '.$queue);
}
$qi->delete();
$qi->free();
@@ -147,7 +151,7 @@ class DBQueueManager extends QueueManager
} else {
if (empty($qi->claimed)) {
$this->_log(LOG_WARNING, 'Ignoring failure for unclaimed queue item '.
- 'for '.$notice->id.', queue '.$queue);
+ 'for '.$notice->id.', queue '.$queue);
} else {
$orig = clone($qi);
$qi->claimed = null;
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php
index e2ba1d003..e1745cfc0 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/scripts/twitterstatusfetcher.php
@@ -330,7 +330,7 @@ class TwitterStatusFetcher extends Daemon
$notice->rendered = common_render_content($notice->content, $notice);
$notice->source = 'twitter';
$notice->reply_to = null; // XXX lookup reply
- $notice->is_local = NOTICE_GATEWAY;
+ $notice->is_local = Notice::GATEWAY;
if (Event::handle('StartNoticeSave', array(&$notice))) {
$id = $notice->insert();