diff --git a/rubygem-rb-inotify-0.9.7-Avoid-crashing-when-fd-is-closed.patch b/rubygem-rb-inotify-0.9.7-Avoid-crashing-when-fd-is-closed.patch new file mode 100644 index 0000000..f7f80f8 --- /dev/null +++ b/rubygem-rb-inotify-0.9.7-Avoid-crashing-when-fd-is-closed.patch @@ -0,0 +1,23 @@ +From 99d2101eaa71adc40737ae45cb03d3ae86fdad4a Mon Sep 17 00:00:00 2001 +From: Cezary Baginski +Date: Fri, 29 Jul 2016 13:26:22 +0200 +Subject: [PATCH] avoid crashing on Ruby 2.3.1 when fd is closed + +--- + lib/rb-inotify/notifier.rb | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/rb-inotify/notifier.rb b/lib/rb-inotify/notifier.rb +index c2f6ddc..516e78f 100644 +--- a/lib/rb-inotify/notifier.rb ++++ b/lib/rb-inotify/notifier.rb +@@ -302,6 +302,9 @@ def readpartial(size) + # If the IO has already been closed, reading from it will cause + # Errno::EBADF. + return nil ++ rescue IOError => ex ++ return nil if ex.message =~ /stream closed/ ++ raise + end + + tries = 0 diff --git a/rubygem-rb-inotify-0.9.7-Prevent-error-when-closing-notifier-in-watch-callback.patch b/rubygem-rb-inotify-0.9.7-Prevent-error-when-closing-notifier-in-watch-callback.patch new file mode 100644 index 0000000..952aef6 --- /dev/null +++ b/rubygem-rb-inotify-0.9.7-Prevent-error-when-closing-notifier-in-watch-callback.patch @@ -0,0 +1,22 @@ +From a3ff7cc8cd7c4e57a4e6d5a885d515946081239f Mon Sep 17 00:00:00 2001 +From: Cezary Baginski +Date: Tue, 3 May 2016 00:03:50 +0200 +Subject: [PATCH] Avoid crashing after fd is closed (fix: #41) + +--- + lib/rb-inotify/event.rb | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/rb-inotify/event.rb b/lib/rb-inotify/event.rb +index f6e9551..11701ac 100644 +--- a/lib/rb-inotify/event.rb ++++ b/lib/rb-inotify/event.rb +@@ -125,7 +125,7 @@ def initialize(data, notifier) + # + # @private + def callback! +- watcher.callback!(self) ++ watcher && watcher.callback!(self) + end + + # Returns the size of this event object in bytes, diff --git a/rubygem-rb-inotify.spec b/rubygem-rb-inotify.spec index 96df54e..e58df20 100644 --- a/rubygem-rb-inotify.spec +++ b/rubygem-rb-inotify.spec @@ -2,12 +2,20 @@ Name: rubygem-%{gem_name} Version: 0.9.7 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A Ruby wrapper for Linux's inotify, using FFI Group: Development/Languages License: MIT URL: http://github.com/nex3/rb-inotify Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem +# The following two patches make rubygem-rerun test suite passing. +# When closing a notifier from within the callback-block of a watch, then +# the process call on the notifier will fail. +# https://github.com/nex3/rb-inotify/issues/41 +Patch0: rubygem-rb-inotify-0.9.7-Prevent-error-when-closing-notifier-in-watch-callback.patch +# Avoid crashing on Ruby 2.3.1 when fd is closed. +# https://github.com/nex3/rb-inotify/pull/59 +Patch1: rubygem-rb-inotify-0.9.7-Avoid-crashing-when-fd-is-closed.patch BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby @@ -30,6 +38,11 @@ Documentation for %{name}. %setup -q -c -T %gem_install -n %{SOURCE0} +pushd .%{gem_instdir} +%patch0 -p1 +%patch1 -p1 +popd + %build %install @@ -55,6 +68,9 @@ cp -a .%{gem_dir}/* \ %changelog +* Tue Sep 06 2016 Vít Ondruch - 0.9.7-2 +- Avoid crashing when fd is closed. + * Fri Jul 01 2016 Vít Ondruch - 0.9.7-1 - Update to rb-inotify 0.9.7.