From 1c9e8480384b016e710be6881bba3519e6a225f4 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 20 Mar 2007 00:27:55 +0000 Subject: rss plugin: lock the mutex on more occasions --- data/rbot/plugins/rss.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'data/rbot/plugins') diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index caebc3fc..69189417 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -53,11 +53,13 @@ class ::RssBlob end def dup - self.class.new(@url, - @handle, - @type ? @type.dup : nil, - @watchers.dup, - @xml ? @xml.dup : nil) + @mutex.synchronize do + self.class.new(@url, + @handle, + @type ? @type.dup : nil, + @watchers.dup, + @xml ? @xml.dup : nil) + end end # Downcase all watchers, possibly turning them into Strings if they weren't @@ -81,12 +83,16 @@ class ::RssBlob if watched_by?(who) return nil end - @watchers << who.downcase + @mutex.synchronize do + @watchers << who.downcase + end return who end def rm_watch(who) - @watchers.delete(who.downcase) + @mutex.synchronize do + @watchers.delete(who.downcase) + end end def to_a @@ -151,9 +157,7 @@ class RSSFeedsPlugin < Plugin def save unparsed = Hash.new() @feeds.each { |k, f| - f.mutex.synchronize do - unparsed[k] = f.dup - end + unparsed[k] = f.dup } @registry[:feeds] = unparsed end -- cgit v1.2.3