summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-08-27 22:51:42 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-08-27 22:51:42 +0000
commit088cea5b9473cbf5796aac0e6104442138a11f07 (patch)
tree20f555b6a4f0274416d8afb87ee9fe0ac595c249
parentbbf05f99728a39280a19d60cc428a40b2f094ce5 (diff)
rss plugin: prevent deadlock between save and watcher threads.
Since the timer fix in [1035], rescheduling ticks the timer, which could cause the timed saving to trigger while a feed mutex was being held. Fix by moving the feed watcher rescheduling out of the mutex synchronization. Also move other calculations out to hold the mutex for as little as necessary.
-rw-r--r--data/rbot/plugins/rss.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb
index 62ce48d9..6451996d 100644
--- a/data/rbot/plugins/rss.rb
+++ b/data/rbot/plugins/rss.rb
@@ -761,12 +761,14 @@ class RSSFeedsPlugin < Plugin
status[:failures] = failures
+ timer = nil
feed.mutex.synchronize do
+ timer = @watch[feed.handle]
seconds = (feed.refresh_rate || @bot.config['rss.thread_sleep']) * (failures + 1)
- seconds += seconds * (rand(100)-50)/100
- debug "watcher for #{feed} going to sleep #{seconds} seconds.."
- @bot.timer.reschedule(@watch[feed.handle], seconds)
end
+ seconds += seconds * (rand(100)-50)/100
+ debug "watcher for #{feed} going to sleep #{seconds} seconds.."
+ @bot.timer.reschedule(timer, seconds)
}
debug "watcher for #{feed} added"
end