Codebase list feed2imap / acb99e3
apply upstream patch to fix usage of filters Closes: #783444 Antonio Terceiro 8 years ago
3 changed file(s) with 80 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 feed2imap (1.2.3-1+deb8u1) jessie; urgency=medium
1
2 * debian/patches/0001-Fix-usage-of-filters.patch: apply upstream patch to
3 fix usage of filters (Closes: #783444)
4
5 -- Antonio Terceiro <terceiro@debian.org> Sun, 10 May 2015 20:08:43 -0300
6
07 feed2imap (1.2.3-1) unstable; urgency=medium
18
29 * New upstream release.
0 From c1e5c1c00bd996140d2a74ee4b5e50182b846bc6 Mon Sep 17 00:00:00 2001
1 From: Antonio Terceiro <terceiro@softwarelivre.org>
2 Date: Sun, 3 May 2015 20:13:29 -0300
3 Subject: [PATCH] Fix usage of filters
4
5 - avoid accessing $? unless it is actually available
6 - when calling a filter, make sure to release the mutex even if there is
7 an exception during the filter handling.
8
9 The long term solution is to drastically reorganize concurrency code.
10 ---
11 feed2imap-test | 5 +++++
12 lib/feed2imap/feed2imap.rb | 35 +++++++++++++++++++----------------
13 2 files changed, 24 insertions(+), 16 deletions(-)
14
15 diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb
16 index 64663c6..b84b6b6 100644
17 --- a/lib/feed2imap/feed2imap.rb
18 +++ b/lib/feed2imap/feed2imap.rb
19 @@ -130,7 +130,7 @@ class Feed2Imap
20 # thread-safe, and we need to get the right exitcode
21 mutex.lock
22 s = %x{#{feed.execurl}}
23 - if $?.exitstatus != 0
24 + if $? && $?.exitstatus != 0
25 @logger.warn("Command for #{feed.name} exited with status #{$?.exitstatus} !")
26 end
27 mutex.unlock
28 @@ -143,22 +143,25 @@ class Feed2Imap
29 # thread-safe, and we need to get the right exitcode.
30 mutex.lock
31 # hack hack hack, avoid buffering problems
32 - stdin, stdout, stderr = Open3::popen3(feed.filter)
33 - inth = Thread::new do
34 - stdin.puts s
35 - stdin.close
36 + begin
37 + stdin, stdout, stderr = Open3::popen3(feed.filter)
38 + inth = Thread::new do
39 + stdin.puts s
40 + stdin.close
41 + end
42 + output = nil
43 + outh = Thread::new do
44 + output = stdout.read
45 + end
46 + inth.join
47 + outh.join
48 + s = output
49 + if $? && $?.exitstatus != 0
50 + @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !")
51 + end
52 + ensure
53 + mutex.unlock
54 end
55 - output = nil
56 - outh = Thread::new do
57 - output = stdout.read
58 - end
59 - inth.join
60 - outh.join
61 - s = output
62 - if $?.exitstatus != 0
63 - @logger.warn("Filter command for #{feed.name} exited with status #{$?.exitstatus}. Output might be corrupted !")
64 - end
65 - mutex.unlock
66 end
67 if Time::now - fetch_start > F2I_WARNFETCHTIME
68 @logger.info("Fetching feed #{feed.name} took #{(Time::now - fetch_start).to_i}s")
69 --
70 2.1.4
71
0 0001-Fix-usage-of-filters.patch