From eca21af74910ed2f325fd72c9a5038d8eff6b37d Mon Sep 17 00:00:00 2001 From: lnu Date: Thu, 3 Apr 2008 12:14:08 +0000 Subject: fix for gna 10516 git-svn-id: svn+ssh://svn.gna.org/svn/feed2imap/trunk/feed2imap@144 f70e237a-67f3-0310-a06c-d2b8a7116972 --- ChangeLog | 2 ++ lib/feed2imap/feed2imap.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index a70c07f..5a0b557 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ Feed2Imap 0.9.3 (XX/02/2008) ============================ +* Check the return code from external commands, and warn if != 0. Fixes + Gna bug #10516. Feed2Imap 0.9.2 (28/10/2007) ============================ diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb index 9a59432..284275a 100644 --- a/lib/feed2imap/feed2imap.rb +++ b/lib/feed2imap/feed2imap.rb @@ -121,16 +121,32 @@ class Feed2Imap if feed.url s = HTTPFetcher::fetch(feed.url, @cache.get_last_check(feed.name)) elsif feed.execurl + # avoid running more than one command at the same time. + # We need it because the called command might not be + # thread-safe, and we need to get the right exitcode + mutex.lock s = %x{#{feed.execurl}} + if $?.exitstatus != 0 + @logger.warn("Command for #{feed.name} exited with status #{$?.exitstatus} !") + end + mutex.unlock else @logger.warn("No way to fetch feed #{feed.name} !") end if feed.filter + # avoid running more than one command at the same time. + # We need it because the called command might not be + # thread-safe, and we need to get the right exitcode. + mutex.lock Open3::popen3(feed.filter) do |stdin, stdout| stdin.puts s stdin.close s = stdout.read end + if $?.exitstatus != 0 + @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !") + end + mutex.unlock end sparefetchers_mutex.synchronize do sparefetchers += 1 -- cgit v1.2.3-70-g09d2