diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-07-04 02:02:13 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-07-04 02:02:13 -0400 |
commit | 3eb131358726ede1d747fbb009073f3932856ec8 (patch) | |
tree | ea7cb317c9495800f4b7fd89e40b0e4abb417b94 | |
parent | 94a7924767779d5c68978d450dbb43d3a5ac1968 (diff) |
don't worry about old claims
darcs-hash:20080704060213-84dde-228a06885e49bc81bb8f0f681ff3dc788c97213c.gz
-rwxr-xr-x | queuedaemon.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/queuedaemon.php b/queuedaemon.php index 97de21490..91cfff0bf 100755 --- a/queuedaemon.php +++ b/queuedaemon.php @@ -41,8 +41,7 @@ function qd_top_item() { $qi = new Queue_item(); $qi->orderBy('created'); - $qi->whereAdd('claimed is NULL', 'OR'); - $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT, 'OR'); + $qi->whereAdd('claimed is NULL'); $qi->limit(1); @@ -52,7 +51,7 @@ function qd_top_item() { # XXX: potential race condition # can we force it to only update if claimed is still NULL # (or old)? - qd_log(LOG_INFO, 'claiming queue item = ' . $queue->notice_id); + qd_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id); $orig = clone($qi); $qi->claimed = DB_DataObject_Cast::dateTime(); $result = $qi->update($orig); @@ -67,6 +66,19 @@ function qd_top_item() { return NULL; } +function qd_clear_old_claims() { + $qi = new Queue_item(); + $qi->orderBy('created'); + $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT); + if ($qi->find()) { + while ($qi->fetch()) { + $orig = clone($qi); + $qi->claimed = NULL; + $qi->update($orig); + } + } +} + function qd_is_remote($notice) { $user = User::staticGet($notice->profile_id); return !$user; @@ -93,6 +105,7 @@ do { $qi->delete(); $qi = NULL; } else { + # qd_clear_old_claims(); # In busy times, sleep less $sleeptime = 30000000/($in_a_row+1); qd_log(LOG_INFO, 'sleeping ' . $sleeptime . ' microseconds'); |