From 088cea5b9473cbf5796aac0e6104442138a11f07 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 27 Aug 2007 22:51:42 +0000 Subject: 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. --- data/rbot/plugins/rss.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'data/rbot/plugins') 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 -- cgit v1.2.3