Hello community,
here is the log from the commit of package perl-Linux-Inotify2 for
openSUSE:Factory checked in at 2018-11-12 09:41:06
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Linux-Inotify2 (Old)
and /work/SRC/openSUSE:Factory/.perl-Linux-Inotify2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Linux-Inotify2"
Mon Nov 12 09:41:06 2018 rev:28 rq:647377 version:2.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Linux-Inotify2/perl-Linux-Inotify2.changes
2012-11-22 16:53:26.000000000 +0100
+++
/work/SRC/openSUSE:Factory/.perl-Linux-Inotify2.new/perl-Linux-Inotify2.changes
2018-11-12 09:41:09.465211957 +0100
@@ -1,0 +2,22 @@
+Thu Nov 8 06:30:22 UTC 2018 - Stephan Kulow <[email protected]>
+
+- updated to 2.1
+ see /usr/share/doc/packages/perl-Linux-Inotify2/Changes
+
+ 2.1 Fri Oct 26 03:16:03 CEST 2018
+ - damn, left debugging code not caught by tests (reported by losyme).
+
+ 2.0 Thu Oct 25 03:19:08 CEST 2018
+ - fix poll and read documentation w.r.t. errors - this changes the
+ documented API, but is how the module has always behaved.
+ - mention https://lwn.net/Articles/605128/ in the docs.
+ - new on_overflow callback, called for overflow events.
+ - new ->broadcast method that calls all watchers with some event.
+ - automatically broadcast overflow events to all watchers by default.
+ - read now returns all events (except ignored ones), not just ones
+ it has registered watchers for (e.g. overflow events).
+ - reduced dependencies (Mike Pomraning).
+ - add IN_EXCL_UNLINK flag.
+ - more efficient constant initialisation.
+
+-------------------------------------------------------------------
Old:
----
Linux-Inotify2-1.22.tar.gz
New:
----
Linux-Inotify2-2.1.tar.gz
cpanspec.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Linux-Inotify2.spec ++++++
--- /var/tmp/diff_new_pack.pG5Tml/_old 2018-11-12 09:41:09.941211276 +0100
+++ /var/tmp/diff_new_pack.pG5Tml/_new 2018-11-12 09:41:09.945211270 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-Linux-Inotify2
#
-# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,36 +12,49 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: perl-Linux-Inotify2
-Summary: scalable directory/file change notification
-License: GPL-1.0+ or Artistic-1.0
-Group: Development/Libraries/Perl
-Version: 1.22
+Version: 2.1
Release: 0
-Url: http://www.cpan.org/modules/by-module/Linux/
-Source: Linux-Inotify2-%{version}.tar.gz
+%define cpan_name Linux-Inotify2
+Summary: Scalable directory/file change notification
+License: GPL-1.0-or-later OR Artistic-1.0
+Group: Development/Libraries/Perl
+Url: https://metacpan.org/release/%{cpan_name}
+Source0:
https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/%{cpan_name}-%{version}.tar.gz
+Source1: cpanspec.yml
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
-BuildRequires: perl-common-sense
BuildRequires: perl-macros
-Requires: perl-common-sense
+BuildRequires: perl(common::sense)
+Requires: perl(common::sense)
%{perl_requires}
%description
-This module implements an interface to the Linux 2.6.13 and later
-Inotify file/directory change notification sytem.
+This module implements an interface to the Linux 2.6.13 and later Inotify
+file/directory change notification system.
+It has a number of advantages over the Linux::Inotify module:
+ - it is portable (Linux::Inotify only works on x86)
+ - the equivalent of fullname works correctly
+ - it is better documented
+ - it has callback-style interface, which is better suited for
+ integration.
+
+As for the inotify API itself - it is a very tricky, and somewhat
+unreliable API. For a good overview of the challenges you might run into,
+see this LWN article: https://lwn.net/Articles/605128/.
%prep
-%setup -q -n Linux-Inotify2-%{version}
+%setup -q -n %{cpan_name}-%{version}
+find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
%build
-perl Makefile.PL
+perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}"
make %{?_smp_mflags}
%check
@@ -50,15 +63,11 @@
%install
%perl_make_install
%perl_process_packlist
+%perl_gen_filelist
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root)
-%doc README Changes MANIFEST COPYING
-%doc %{_mandir}/man3/*Inotify2*.gz
-%{perl_vendorarch}/auto/Linux
-%{perl_vendorarch}/Linux
+%files -f %{name}.files
+%defattr(-,root,root,755)
+%doc Changes README
+%license COPYING
%changelog
++++++ Linux-Inotify2-1.22.tar.gz -> Linux-Inotify2-2.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/Changes
new/Linux-Inotify2-2.1/Changes
--- old/Linux-Inotify2-1.22/Changes 2011-06-14 08:41:28.000000000 +0200
+++ new/Linux-Inotify2-2.1/Changes 2018-10-26 03:16:08.000000000 +0200
@@ -3,6 +3,22 @@
TODO: document move/renaming issues for fullname
TODO: find_watchers($path), or maybe just ->watchers
+2.1 Fri Oct 26 03:16:03 CEST 2018
+ - damn, left debugging code not caught by tests (reported by losyme).
+
+2.0 Thu Oct 25 03:19:08 CEST 2018
+ - fix poll and read documentation w.r.t. errors - this changes the
+ documented API, but is how the module has always behaved.
+ - mention https://lwn.net/Articles/605128/ in the docs.
+ - new on_overflow callback, called for overflow events.
+ - new ->broadcast method that calls all watchers with some event.
+ - automatically broadcast overflow events to all watchers by default.
+ - read now returns all events (except ignored ones), not just ones
+ it has registered watchers for (e.g. overflow events).
+ - reduced dependencies (Mike Pomraning).
+ - add IN_EXCL_UNLINK flag.
+ - more efficient constant initialisation.
+
1.22 Tue Jun 14 08:34:38 CEST 2011
- use a more useful definition of IN_xxx methods - any bits, not
a match. (pointed out by Anatoliy Grishayev).
@@ -30,7 +46,7 @@
- removed debugging code accidentally left in.
- streaming API didn't always return properly blessed objects.
-1.0 Mon Dec 19 17:48:01 CET 2005
+1.0 Mon Dec 19 17:48:01 CET 2005
- incorporated a major patch by Andrejs Dubovskis:
- added a non-callback interface to read events
- better error handling in non-blocking case.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/Inotify2.pm
new/Linux-Inotify2-2.1/Inotify2.pm
--- old/Linux-Inotify2-1.22/Inotify2.pm 2011-06-14 08:41:39.000000000 +0200
+++ new/Linux-Inotify2-2.1/Inotify2.pm 2018-10-26 03:16:14.000000000 +0200
@@ -26,32 +26,26 @@
});
# integration into AnyEvent (works with EV, Glib, Tk, POE...)
- my $inotify_w = AnyEvent->io (
- fh => $inofity->fileno, poll => 'r', cb => sub { $inotify->poll }
- );
+ my $inotify_w = AE::io $inotify->fileno, 0, sub { $inotify->poll };
# manual event loop
- 1 while $inotify->poll;
+ $inotify->poll while 1;
=head2 Streaming Interface
- use Linux::Inotify2 ;
+ use Linux::Inotify2;
# create a new object
my $inotify = new Linux::Inotify2
- or die "Unable to create new inotify object: $!" ;
+ or die "Unable to create new inotify object: $!";
# create watch
$inotify->watch ("/etc/passwd", IN_ACCESS)
- or die "watch creation failed" ;
+ or die "watch creation failed";
while () {
my @events = $inotify->read;
- unless (@events > 0) {
- print "read error: $!";
- last ;
- }
- printf "mask\t%d\n", $_->mask foreach @events ;
+ printf "mask\t%d\n", $_->mask foreach @events;
}
=head1 DESCRIPTION
@@ -67,6 +61,10 @@
- it has callback-style interface, which is better suited for
integration.
+As for the inotify API itself - it is a very tricky, and somewhat
+unreliable API. For a good overview of the challenges you might run into,
+see this LWN article: L<https://lwn.net/Articles/605128/>.
+
=head2 The Linux::Inotify2 Class
=over 4
@@ -75,16 +73,14 @@
package Linux::Inotify2;
-use Carp ();
-use Fcntl ();
use Scalar::Util ();
use common::sense;
-use base 'Exporter';
+use Exporter qw(import);
BEGIN {
- our $VERSION = '1.22';
+ our $VERSION = '2.1';
our @EXPORT = qw(
IN_ACCESS IN_MODIFY IN_ATTRIB IN_CLOSE_WRITE
IN_CLOSE_NOWRITE IN_OPEN IN_MOVED_FROM IN_MOVED_TO
@@ -92,7 +88,8 @@
IN_ALL_EVENTS
IN_UNMOUNT IN_Q_OVERFLOW IN_IGNORED
IN_CLOSE IN_MOVE
- IN_ISDIR IN_ONESHOT IN_MASK_ADD IN_DONT_FOLLOW IN_ONLYDIR
+ IN_ISDIR IN_ONESHOT IN_MASK_ADD
+ IN_DONT_FOLLOW IN_EXCL_UNLINK IN_ONLYDIR
);
require XSLoader;
@@ -155,7 +152,8 @@
IN_ONESHOT only send event once
IN_ONLYDIR only watch the path if it is a directory
- IN_DONT_FOLLOW don't follow a sym link
+ IN_DONT_FOLLOW don't follow a sym link (Linux 2.6.15+)
+ IN_EXCL_UNLINK don't create events for unlinked objects (Linux 2.6.36+)
IN_MASK_ADD not supported with the current version of this module
IN_CLOSE same as IN_CLOSE_WRITE | IN_CLOSE_NOWRITE
@@ -237,10 +235,13 @@
Reads events from the kernel and handles them. If the notify file
descriptor is blocking (the default), then this method waits for at least
-one event (and thus returns true unless an error occurs). Otherwise it
-returns immediately when no pending events could be read.
+one event. Otherwise it returns immediately when no pending events could
+be read.
-Returns the count of events that have been handled.
+Returns the count of events that have been handled (which can be C<0> in case
+events have been received but have been ignored or handled internally).
+
+Croaks when an error occurs.
=cut
@@ -253,7 +254,9 @@
Reads events from the kernel. Blocks when the file descriptor is in
blocking mode (default) until any event arrives. Returns list of
C<Linux::Inotify2::Event> objects or empty list if none (non-blocking
-mode) or error occurred ($! should be checked).
+mode or events got ignored).
+
+Croaks on error.
Normally you shouldn't use this function, but instead use watcher
callbacks and call C<< ->poll >>.
@@ -267,23 +270,69 @@
my @res;
for (@ev) {
- my $w = $_->{w} = $self->{w}{$_->{wd}}
- or next; # no such watcher
-
exists $self->{ignore}{$_->{wd}}
and next; # watcher has been canceled
- bless $_, "Linux::Inotify2::Event";
+ push @res, bless $_, "Linux::Inotify2::Event";
- push @res, $_;
+ my $w = $_->{w} = $self->{w}{$_->{wd}}
+ or do {
+ # no such watcher, but maybe we can do overflow handling
+ if ($_->{mask} & IN_Q_OVERFLOW) {
+ if ($self->{on_overflow}) {
+ $self->{on_overflow}($_);
+ } else {
+ $self->broadcast ($_);
+ }
+ }
+ next;
+ };
- $w->{cb}->($_) if $w->{cb};
+ $w->{cb}($_) if $w->{cb};
$w->cancel if $_->{mask} & (IN_IGNORED | IN_UNMOUNT | IN_ONESHOT |
IN_DELETE_SELF);
}
delete $self->{ignore};
- @res
+ wantarray ? @res : scalar @res
+}
+
+=item $inotify->on_overflow ($cb->($ev))
+
+Sets the callback to be used for overflow handling
+(default: C<undef>): When C<read> receives an event with C<IN_Q_OVERFLOW>
+set, it will invoke this callback with the event.
+
+When the callback is C<undef>, then it broadcasts the event to all
+registered watchers, i.e., C<undef> is equivalent to:
+
+ sub { $inotify->broadcast ($_[0]) }
+
+=cut
+
+sub on_overflow {
+ my $prev = $_[0]{on_overflow};
+
+ $_[0]{on_overflow} = $_[1]
+ if @_ >= 2;
+
+ $prev
+}
+
+=item $inotify->broadcast ($ev)
+
+Invokes all registered watcher callbacks and passes the given event to
+them. Most useful in overflow handlers.
+
+=cut
+
+sub broadcast {
+ my ($self, $ev) = @_;
+
+ for my $w (values %{ $self->{w} }) {
+ local $ev->{w} = $w;
+ $w->{cb}($ev) if $w->{cb};
+ }
}
sub DESTROY {
@@ -303,7 +352,8 @@
=item $event->{w}
-The watcher object for this event.
+The watcher object for this event, if one is available. Generally, you cna
+only rely on the value of this member inside watcher callbacks.
=item $event->name
@@ -318,6 +368,9 @@
directory entry is affected), or simply the C<name> member itself when the
object is the watch object itself.
+This call requires C<< $event->{w} >> to be valid, which is generally only
+the case within watcher callbacks.
+
=item $event->mask
=item $event->{mask}
@@ -333,6 +386,7 @@
IN_UNMOUNT filesystem for watched object was unmounted
IN_IGNORED file was ignored/is gone (no more events are delivered)
IN_ONESHOT only one event was generated
+ IN_Q_OVERFLOW queue overflow - event might not be specific to a watcher
=item $event->IN_xxx
@@ -349,6 +403,13 @@
know, this only happens for C<IN_MOVED_FROM> and C<IN_MOVED_TO> events, to
identify the old and new name of a file.
+Note that the inotify API makes it impossible to know whether there will
+be a C<IN_MOVED_TO> event - you might receive only one of the events,
+and even if you receive both, there might be any number of events in
+between. The best approach seems to be to implement a small timeout
+after C<IN_MOVED_FROM> to see if a matching C<IN_MOVED_TO> event will be
+received - 2ms seem to work relatively well.
+
=back
=cut
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/Inotify2.xs
new/Linux-Inotify2-2.1/Inotify2.xs
--- old/Linux-Inotify2-1.22/Inotify2.xs 2008-10-07 19:22:18.000000000 +0200
+++ new/Linux-Inotify2-2.1/Inotify2.xs 2018-07-07 16:16:36.000000000 +0200
@@ -15,31 +15,39 @@
BOOT:
{
- HV *stash = gv_stashpv ("Linux::Inotify2", 0);
+ HV *stash = GvSTASH (CvGV (cv));
- newCONSTSUB (stash, "IN_ACCESS" , newSViv (IN_ACCESS));
- newCONSTSUB (stash, "IN_MODIFY" , newSViv (IN_MODIFY));
- newCONSTSUB (stash, "IN_ATTRIB" , newSViv (IN_ATTRIB));
- newCONSTSUB (stash, "IN_CLOSE_WRITE" , newSViv (IN_CLOSE_WRITE
));
- newCONSTSUB (stash, "IN_CLOSE_NOWRITE", newSViv (IN_CLOSE_NOWRITE));
- newCONSTSUB (stash, "IN_OPEN" , newSViv (IN_OPEN));
- newCONSTSUB (stash, "IN_MOVED_FROM" , newSViv (IN_MOVED_FROM));
- newCONSTSUB (stash, "IN_MOVED_TO" , newSViv (IN_MOVED_TO));
- newCONSTSUB (stash, "IN_CREATE" , newSViv (IN_CREATE));
- newCONSTSUB (stash, "IN_DELETE" , newSViv (IN_DELETE));
- newCONSTSUB (stash, "IN_DELETE_SELF" , newSViv (IN_DELETE_SELF));
- newCONSTSUB (stash, "IN_MOVE_SELF" , newSViv (IN_MOVE_SELF));
- newCONSTSUB (stash, "IN_UNMOUNT" , newSViv (IN_UNMOUNT));
- newCONSTSUB (stash, "IN_Q_OVERFLOW" , newSViv (IN_Q_OVERFLOW));
- newCONSTSUB (stash, "IN_IGNORED" , newSViv (IN_IGNORED));
- newCONSTSUB (stash, "IN_CLOSE" , newSViv (IN_CLOSE));
- newCONSTSUB (stash, "IN_MOVE" , newSViv (IN_MOVE));
- newCONSTSUB (stash, "IN_ONLYDIR" , newSViv (IN_ONLYDIR));
- newCONSTSUB (stash, "IN_DONT_FOLLOW" , newSViv (IN_DONT_FOLLOW));
- newCONSTSUB (stash, "IN_MASK_ADD" , newSViv (IN_MASK_ADD));
- newCONSTSUB (stash, "IN_ISDIR" , newSViv (IN_ISDIR));
- newCONSTSUB (stash, "IN_ONESHOT" , newSViv (IN_ONESHOT));
- newCONSTSUB (stash, "IN_ALL_EVENTS" , newSViv (IN_ALL_EVENTS));
+ static const struct civ { const char *name; IV iv; } *civ, const_iv[]
= {
+ { "IN_ACCESS" , IN_ACCESS },
+ { "IN_MODIFY" , IN_MODIFY },
+ { "IN_ATTRIB" , IN_ATTRIB },
+ { "IN_CLOSE_WRITE" , IN_CLOSE_WRITE },
+ { "IN_CLOSE_NOWRITE", IN_CLOSE_NOWRITE },
+ { "IN_OPEN" , IN_OPEN },
+ { "IN_MOVED_FROM" , IN_MOVED_FROM },
+ { "IN_MOVED_TO" , IN_MOVED_TO },
+ { "IN_CREATE" , IN_CREATE },
+ { "IN_DELETE" , IN_DELETE },
+ { "IN_DELETE_SELF" , IN_DELETE_SELF },
+ { "IN_MOVE_SELF" , IN_MOVE_SELF },
+ { "IN_UNMOUNT" , IN_UNMOUNT },
+ { "IN_Q_OVERFLOW" , IN_Q_OVERFLOW },
+ { "IN_IGNORED" , IN_IGNORED },
+ { "IN_CLOSE" , IN_CLOSE },
+ { "IN_MOVE" , IN_MOVE },
+ { "IN_ONLYDIR" , IN_ONLYDIR },
+ { "IN_DONT_FOLLOW" , IN_DONT_FOLLOW },
+#if IN_EXCL_UNLINK
+ { "IN_EXCL_UNLINK" , IN_EXCL_UNLINK },
+#endif
+ { "IN_MASK_ADD" , IN_MASK_ADD },
+ { "IN_ISDIR" , IN_ISDIR },
+ { "IN_ONESHOT" , IN_ONESHOT },
+ { "IN_ALL_EVENTS" , IN_ALL_EVENTS },
+ };
+
+ for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ >
const_iv; civ--)
+ newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
}
int
@@ -58,7 +66,7 @@
int
inotify_blocking (int fd, I32 blocking)
- CODE:
+ CODE:
fcntl (fd, F_SETFL, blocking ? 0 : O_NONBLOCK);
void
@@ -95,4 +103,3 @@
}
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/MANIFEST
new/Linux-Inotify2-2.1/MANIFEST
--- old/Linux-Inotify2-1.22/MANIFEST 2011-06-14 08:41:43.000000000 +0200
+++ new/Linux-Inotify2-2.1/MANIFEST 2018-10-26 03:16:17.000000000 +0200
@@ -9,4 +9,5 @@
eg/event
t/00_load.t
t/01_inotify.t
-META.json Module meta-data (added by MakeMaker)
+META.yml Module YAML meta-data (added by
MakeMaker)
+META.json Module JSON meta-data (added by
MakeMaker)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/META.json
new/Linux-Inotify2-2.1/META.json
--- old/Linux-Inotify2-1.22/META.json 2011-06-14 08:41:43.000000000 +0200
+++ new/Linux-Inotify2-2.1/META.json 2018-10-26 03:16:16.000000000 +0200
@@ -1,28 +1,42 @@
{
+ "abstract" : "unknown",
+ "author" : [
+ "unknown"
+ ],
+ "dynamic_config" : 1,
+ "generated_by" : "ExtUtils::MakeMaker version 7.32, CPAN::Meta::Converter
version 2.150010",
+ "license" : [
+ "unknown"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Linux-Inotify2",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
- "meta-spec" : {
- "version" : 1.4,
- "url" : "http://module-build.sourceforge.net/META-spec-v1.4.html"
- },
- "generated_by" : "ExtUtils::MakeMaker::JSONMETA version 7.000",
- "distribution_type" : "module",
- "version" : "1.22",
- "name" : "Linux-Inotify2",
- "author" : [],
- "license" : "unknown",
- "build_requires" : {
- "ExtUtils::MakeMaker" : 0
- },
- "requires" : {
- "common::sense" : 0
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "0"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "common::sense" : "0"
+ }
+ }
},
- "abstract" : null,
- "configure_requires" : {
- "ExtUtils::MakeMaker" : 0
- }
+ "release_status" : "stable",
+ "version" : "2.1",
+ "x_serialization_backend" : "JSON::PP version 2.27300"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/META.yml
new/Linux-Inotify2-2.1/META.yml
--- old/Linux-Inotify2-1.22/META.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/Linux-Inotify2-2.1/META.yml 2018-10-26 03:16:16.000000000 +0200
@@ -0,0 +1,23 @@
+---
+abstract: unknown
+author:
+ - unknown
+build_requires:
+ ExtUtils::MakeMaker: '0'
+configure_requires:
+ ExtUtils::MakeMaker: '0'
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 7.32, CPAN::Meta::Converter version
2.150010'
+license: unknown
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: '1.4'
+name: Linux-Inotify2
+no_index:
+ directory:
+ - t
+ - inc
+requires:
+ common::sense: '0'
+version: '2.1'
+x_serialization_backend: 'CPAN::Meta::YAML version 0.012'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Linux-Inotify2-1.22/README
new/Linux-Inotify2-2.1/README
--- old/Linux-Inotify2-1.22/README 2011-06-14 08:41:43.000000000 +0200
+++ new/Linux-Inotify2-2.1/README 2018-10-26 03:16:17.000000000 +0200
@@ -23,31 +23,25 @@
});
# integration into AnyEvent (works with EV, Glib, Tk, POE...)
- my $inotify_w = AnyEvent->io (
- fh => $inofity->fileno, poll => 'r', cb => sub { $inotify->poll }
- );
+ my $inotify_w = AE::io $inotify->fileno, 0, sub { $inotify->poll };
# manual event loop
- 1 while $inotify->poll;
+ $inotify->poll while 1;
Streaming Interface
- use Linux::Inotify2 ;
+ use Linux::Inotify2;
# create a new object
my $inotify = new Linux::Inotify2
- or die "Unable to create new inotify object: $!" ;
+ or die "Unable to create new inotify object: $!";
# create watch
$inotify->watch ("/etc/passwd", IN_ACCESS)
- or die "watch creation failed" ;
+ or die "watch creation failed";
while () {
my @events = $inotify->read;
- unless (@events > 0) {
- print "read error: $!";
- last ;
- }
- printf "mask\t%d\n", $_->mask foreach @events ;
+ printf "mask\t%d\n", $_->mask foreach @events;
}
DESCRIPTION
@@ -62,6 +56,10 @@
- it has callback-style interface, which is better suited for
integration.
+ As for the inotify API itself - it is a very tricky, and somewhat
+ unreliable API. For a good overview of the challenges you might run
+ into, see this LWN article: <https://lwn.net/Articles/605128/>.
+
The Linux::Inotify2 Class
my $inotify = new Linux::Inotify2
Create a new notify object and return it. A notify object is kind of
@@ -106,7 +104,8 @@
IN_ONESHOT only send event once
IN_ONLYDIR only watch the path if it is a directory
- IN_DONT_FOLLOW don't follow a sym link
+ IN_DONT_FOLLOW don't follow a sym link (Linux 2.6.15+)
+ IN_EXCL_UNLINK don't create events for unlinked objects (Linux
2.6.36+)
IN_MASK_ADD not supported with the current version of this
module
IN_CLOSE same as IN_CLOSE_WRITE | IN_CLOSE_NOWRITE
@@ -150,28 +149,49 @@
$count = $inotify->poll
Reads events from the kernel and handles them. If the notify file
descriptor is blocking (the default), then this method waits for at
- least one event (and thus returns true unless an error occurs).
- Otherwise it returns immediately when no pending events could be
- read.
+ least one event. Otherwise it returns immediately when no pending
+ events could be read.
+
+ Returns the count of events that have been handled (which can be 0
+ in case events have been received but have been ignored or handled
+ internally).
- Returns the count of events that have been handled.
+ Croaks when an error occurs.
@events = $inotify->read
Reads events from the kernel. Blocks when the file descriptor is in
blocking mode (default) until any event arrives. Returns list of
"Linux::Inotify2::Event" objects or empty list if none (non-blocking
- mode) or error occurred ($! should be checked).
+ mode or events got ignored).
+
+ Croaks on error.
Normally you shouldn't use this function, but instead use watcher
callbacks and call "->poll".
+ $inotify->on_overflow ($cb->($ev))
+ Sets the callback to be used for overflow handling (default:
+ "undef"): When "read" receives an event with "IN_Q_OVERFLOW" set, it
+ will invoke this callback with the event.
+
+ When the callback is "undef", then it broadcasts the event to all
+ registered watchers, i.e., "undef" is equivalent to:
+
+ sub { $inotify->broadcast ($_[0]) }
+
+ $inotify->broadcast ($ev)
+ Invokes all registered watcher callbacks and passes the given event
+ to them. Most useful in overflow handlers.
+
The Linux::Inotify2::Event Class
Objects of this class are handed as first argument to the watcher
callback. It has the following members and methods:
$event->w
$event->{w}
- The watcher object for this event.
+ The watcher object for this event, if one is available. Generally,
+ you cna only rely on the value of this member inside watcher
+ callbacks.
$event->name
$event->{name}
@@ -183,6 +203,9 @@
and a directory entry is affected), or simply the "name" member
itself when the object is the watch object itself.
+ This call requires "$event->{w}" to be valid, which is generally
+ only the case within watcher callbacks.
+
$event->mask
$event->{mask}
The received event mask. In addition to the events described for
@@ -197,6 +220,7 @@
IN_UNMOUNT filesystem for watched object was unmounted
IN_IGNORED file was ignored/is gone (no more events are
delivered)
IN_ONESHOT only one event was generated
+ IN_Q_OVERFLOW queue overflow - event might not be specific to
a watcher
$event->IN_xxx
Returns a boolean that returns true if the event mask contains any
@@ -211,6 +235,14 @@
and "IN_MOVED_TO" events, to identify the old and new name of a
file.
+ Note that the inotify API makes it impossible to know whether there
+ will be a "IN_MOVED_TO" event - you might receive only one of the
+ events, and even if you receive both, there might be any number of
+ events in between. The best approach seems to be to implement a
+ small timeout after "IN_MOVED_FROM" to see if a matching
+ "IN_MOVED_TO" event will be received - 2ms seem to work relatively
+ well.
+
The Linux::Inotify2::Watch Class
Watcher objects are created by calling the "watch" method of a notifier.
++++++ cpanspec.yml ++++++
---
#description_paragraphs: 3
#description: |-
# override description from CPAN
#summary: override summary from CPAN
#no_testing: broken upstream
#sources:
# - source1
# - source2
#patches:
# foo.patch: -p1
# bar.patch:
#preamble: |-
# BuildRequires: gcc-c++
#post_prep: |-
# hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s, *,,g'`
# sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL
#post_build: |-
# rm unused.files
#post_install: |-
# sed on %{name}.files
license: GPL-1.0-or-later or Artistic-1.0
#skip_noarch: 1
#custom_build: |-
#./Build build flags=%{?_smp_mflags} --myflag
#custom_test: |-
#startserver && make test
#ignore_requires: Bizarre::Module