summaryrefslogtreecommitdiff
path: root/lib/feed2imap
diff options
context:
space:
mode:
authorlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2007-10-03 18:30:57 +0000
committerlnu <lnu@f70e237a-67f3-0310-a06c-d2b8a7116972>2007-10-03 18:30:57 +0000
commitcedab3030800afe93ca5efdacc75706af2957847 (patch)
tree344cb56ca42b7c68da7d2c571dfcd8a251421a3b /lib/feed2imap
parentf38cb10a99b5e999ad21a193ef97f22c032e727f (diff)
downloadfeed2imap-cedab3030800afe93ca5efdacc75706af2957847.tar.gz
feed2imap-cedab3030800afe93ca5efdacc75706af2957847.tar.bz2
feed2imap-cedab3030800afe93ca5efdacc75706af2957847.zip
fix max fetchers code ; dont update cache when uploading failed
git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@132 f70e237a-67f3-0310-a06c-d2b8a7116972
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/feed2imap.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb
index c46ff3b..061e8c6 100644
--- a/lib/feed2imap/feed2imap.rb
+++ b/lib/feed2imap/feed2imap.rb
@@ -102,7 +102,7 @@ class Feed2Imap
@logger.info("Fetching and filtering feeds ...")
ths = []
mutex = Mutex::new
- sparefetchers = 8 # max number of fetchers running at the same time.
+ sparefetchers = 16 # max number of fetchers running at the same time.
sparefetchers_mutex = Mutex::new
sparefetchers_cond = ConditionVariable::new
@config.feeds.each do |f|
@@ -113,11 +113,10 @@ class Feed2Imap
if feed.needfetch(lastcheck)
mutex.unlock
sparefetchers_mutex.synchronize do
- if sparefetchers <= 0
+ while sparefetchers <= 0
sparefetchers_cond.wait(sparefetchers_mutex)
- else
- sparefetchers -= 1
end
+ sparefetchers -= 1
end
if feed.url
s = HTTPFetcher::fetch(feed.url, @cache.get_last_check(feed.name))
@@ -188,6 +187,7 @@ class Feed2Imap
ths.each { |t| t.join }
@logger.info("Parsing and uploading ...")
@config.feeds.each do |f|
+ everything_ok = true
if f.body.nil? # means 304
@logger.debug("Feed #{f.name} did not change.")
next
@@ -228,10 +228,15 @@ class Feed2Imap
rescue
@logger.fatal("Exception caught while uploading mail to #{f.folder}: #{$!}")
puts $!.backtrace
+ everything_ok = false
next
end
begin
- @cache.commit_cache(f.name)
+ if everything_ok
+ @cache.commit_cache(f.name)
+ else
+ @logger.fatal("Not updating cache for #{f.name} because something went wrong earlier.")
+ end
rescue
@logger.fatal("Exception caught while updating cache for #{f.name}: #{$!}")
next