Mikolaj Kucharski writes:
> So, File::ChangeNotify doesn't handle resource limits gracefuly,
> yeah[ref#2]? If that is true, your changes make sense for me.
Yes, exactly. The KQueue-based watcher class doesn't fall back to
polling if it runs out of file descriptors.
I've attached an updated diff. This version of the port creates a
p5-File-ChangeNotify-Watcher-KQueue package in addition to the main
package. The main package provides the slow default watcher that doesn't
require any further configuration. As soon as the sub package is
installed the KQueue-based watcher becomes the default.
Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/p5-File-ChangeNotify/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- Makefile 3 Dec 2010 11:44:31 -0000 1.5
+++ Makefile 1 Jan 2011 17:25:18 -0000
@@ -1,25 +1,34 @@
# $OpenBSD: Makefile,v 1.5 2010/12/03 11:44:31 ajacoutot Exp $
-COMMENT= watch for changes to files, cross-platform style
+COMMENT-main= watch for changes to files, cross-platform style
+COMMENT-kqueue= watch for changes to files (KQueue-based)
MODULES= cpan
-DISTNAME= File-ChangeNotify-0.13
-REVISION= 0
+DISTNAME= File-ChangeNotify-0.19
+PKGNAME-main= p5-File-ChangeNotify-0.19
+PKGNAME-kqueue= p5-File-ChangeNotify-Watcher-KQueue-0.19
CATEGORIES= devel
-# Perl
+# Artistic 2.0
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
+MULTI_PACKAGES = -main -kqueue
+
CONFIGURE_STYLE = modbuild
-USE_GROFF = Yes
-RUN_DEPENDS = devel/p5-Class-MOP \
- devel/p5-Moose \
- devel/p5-MooseX-Params-Validate \
- devel/p5-MooseX-SemiAffordanceAccessor
+BUILD_DEPENDS = ${RUN_DEPENDS-main} \
+ devel/p5-IO-KQueue
+RUN_DEPENDS-main = devel/p5-Class-MOP \
+ devel/p5-Moose \
+ devel/p5-MooseX-Params-Validate \
+ devel/p5-MooseX-SemiAffordanceAccessor \
+ devel/p5-namespace-autoclean
+RUN_DEPENDS-kqueue = devel/p5-File-ChangeNotify \
+ devel/p5-IO-KQueue
+REGRESS_DEPENDS = devel/p5-Test-Exception
MAKE_ENV += TEST_POD=1 IS_MAINTAINER=1
Index: distinfo
===================================================================
RCS file: /cvs/ports/devel/p5-File-ChangeNotify/distinfo,v
retrieving revision 1.2
diff -u -r1.2 distinfo
--- distinfo 3 Jul 2010 03:41:42 -0000 1.2
+++ distinfo 1 Jan 2011 17:25:18 -0000
@@ -1,5 +1,5 @@
-MD5 (File-ChangeNotify-0.13.tar.gz) = eR70uZegW1BwTiwo+Ph4oA==
-RMD160 (File-ChangeNotify-0.13.tar.gz) = Jltiid+UQa63uHcm5mBS2KnQ69s=
-SHA1 (File-ChangeNotify-0.13.tar.gz) = WcEiFJwmsqrqCjYp2xNnbAlSbqM=
-SHA256 (File-ChangeNotify-0.13.tar.gz) =
yHAoVdthRnb9v2P9raOA6tj2FAE11Y1TkUQuDYmpaig=
-SIZE (File-ChangeNotify-0.13.tar.gz) = 18155
+MD5 (File-ChangeNotify-0.19.tar.gz) = VQwjU6nvRVIDu8AC7DGr+A==
+RMD160 (File-ChangeNotify-0.19.tar.gz) = AR00UgFZUSdOzuYz8k9v6hycoho=
+SHA1 (File-ChangeNotify-0.19.tar.gz) = kHUhoX7Qh7eHUQZHMhP2WNo+WaE=
+SHA256 (File-ChangeNotify-0.19.tar.gz) =
8UfmQPMm0uG3XrKZ+1LXcDXbEE+evsc71IuEhBOXAdA=
+SIZE (File-ChangeNotify-0.19.tar.gz) = 19908
Index: patches/patch-lib_File_ChangeNotify_Watcher_KQueue_pm
===================================================================
RCS file: patches/patch-lib_File_ChangeNotify_Watcher_KQueue_pm
diff -N patches/patch-lib_File_ChangeNotify_Watcher_KQueue_pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_File_ChangeNotify_Watcher_KQueue_pm 1 Jan 2011
17:25:18 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+--- lib/File/ChangeNotify/Watcher/KQueue.pm.orig Sun Oct 17 22:00:14 2010
++++ lib/File/ChangeNotify/Watcher/KQueue.pm Sat Jan 1 10:21:31 2011
+@@ -184,7 +184,7 @@ sub _watch_file {
+
+ # Don't panic if we can't open a file
+ open my $fh, '<', $file or warn "Can't open '$file': $!";
+- return unless $fh;
++ return unless $fh && defined fileno($fh);
+
+ # Store this filehandle (this will automatically nuke any existing events
+ # assigned to the file)
+@@ -229,6 +229,10 @@ On FreeBSD, you can check (and alter) your system's se
+ necessary. The important keys are: C<kern.maxfiles> and
+ C<kern.maxfilesperproc>. You can see how many files your system current has
+ open with C<kern.openfiles>.
++
++On OpenBSD, the C<sysctl> keys are C<kern.maxfiles> and C<kern.nfiles>.
++Per-process limits are set in F</etc/login.conf>. See L<login.conf(5)> and
++L<BSD::Resource> for details.
+
+ =head1 SUPPORT
+
Index: pkg/DESCR
===================================================================
RCS file: pkg/DESCR
diff -N pkg/DESCR
--- pkg/DESCR 27 Oct 2009 00:31:20 -0000 1.1.1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
-Watch for changes to files, cross-platform style via an API for creating
-a File::ChangeNotify::Watcher subclass that will work on your platform.
Index: pkg/DESCR-kqueue
===================================================================
RCS file: pkg/DESCR-kqueue
diff -N pkg/DESCR-kqueue
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/DESCR-kqueue 1 Jan 2011 17:25:18 -0000
@@ -0,0 +1,5 @@
+Watch for changes to files, cross-platform style via an API for creating
+a File::ChangeNotify::Watcher subclass that will work on your platform.
+
+This package provides a KQueue-based watcher subclass that is more
+efficient than the default watcher subclass.
Index: pkg/DESCR-main
===================================================================
RCS file: pkg/DESCR-main
diff -N pkg/DESCR-main
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/DESCR-main 1 Jan 2011 17:25:18 -0000
@@ -0,0 +1,7 @@
+Watch for changes to files, cross-platform style via an API for creating
+a File::ChangeNotify::Watcher subclass that will work on your platform.
+
+This package provides a slow but simple watcher subclass that will work
+without further configuration. A more efficient watcher class, that
+requires additional system configuration, is provided by the package
+p5-File-ChangeNotify-Watcher-KQueue.
Index: pkg/MESSAGE-kqueue
===================================================================
RCS file: pkg/MESSAGE-kqueue
diff -N pkg/MESSAGE-kqueue
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/MESSAGE-kqueue 1 Jan 2011 17:25:18 -0000
@@ -0,0 +1,4 @@
+The File::ChangeNotify::Watcher::KQueue watcher class does not fall back
+to polling if it runs out of file descriptors. To prevent errors
+increase the kern.maxfiles sysctl(8) and adapt the login(1) class
+accordingly.
Index: pkg/PLIST
===================================================================
RCS file: pkg/PLIST
diff -N pkg/PLIST
--- pkg/PLIST 3 Jul 2010 03:41:42 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,18 +0,0 @@
-...@comment $OpenBSD: PLIST,v 1.2 2010/07/03 03:41:42 jim Exp $
-${P5SITE}/File/
-${P5SITE}/File/ChangeNotify/
-${P5SITE}/File/ChangeNotify.pm
-${P5SITE}/File/ChangeNotify/ConfigData.pm
-${P5SITE}/File/ChangeNotify/Event.pm
-${P5SITE}/File/ChangeNotify/Watcher/
-${P5SITE}/File/ChangeNotify/Watcher.pm
-${P5SITE}/File/ChangeNotify/Watcher/Default.pm
-${P5SITE}/File/ChangeNotify/Watcher/Inotify.pm
-${P5SITE}/File/ChangeNotify/Watcher/KQueue.pm
-...@man man/man3p/File::ChangeNotify.3p
-...@man man/man3p/File::ChangeNotify::ConfigData.3p
-...@man man/man3p/File::ChangeNotify::Event.3p
-...@man man/man3p/File::ChangeNotify::Watcher.3p
-...@man man/man3p/File::ChangeNotify::Watcher::Default.3p
-...@man man/man3p/File::ChangeNotify::Watcher::Inotify.3p
-...@man man/man3p/File::ChangeNotify::Watcher::KQueue.3p
Index: pkg/PLIST-kqueue
===================================================================
RCS file: pkg/PLIST-kqueue
diff -N pkg/PLIST-kqueue
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/PLIST-kqueue 1 Jan 2011 17:25:18 -0000
@@ -0,0 +1,3 @@
+...@comment $OpenBSD$
+${P5SITE}/File/ChangeNotify/Watcher/KQueue.pm
+...@man man/man3p/File::ChangeNotify::Watcher::KQueue.3p
Index: pkg/PLIST-main
===================================================================
RCS file: pkg/PLIST-main
diff -N pkg/PLIST-main
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ pkg/PLIST-main 1 Jan 2011 17:25:18 -0000
@@ -0,0 +1,16 @@
+...@comment $OpenBSD: PLIST,v 1.2 2010/07/03 03:41:42 jim Exp $
+${P5SITE}/File/
+${P5SITE}/File/ChangeNotify/
+${P5SITE}/File/ChangeNotify.pm
+${P5SITE}/File/ChangeNotify/ConfigData.pm
+${P5SITE}/File/ChangeNotify/Event.pm
+${P5SITE}/File/ChangeNotify/Watcher/
+${P5SITE}/File/ChangeNotify/Watcher.pm
+${P5SITE}/File/ChangeNotify/Watcher/Default.pm
+...@comment ${P5SITE}/File/ChangeNotify/Watcher/Inotify.pm
+...@man man/man3p/File::ChangeNotify.3p
+...@man man/man3p/File::ChangeNotify::ConfigData.3p
+...@man man/man3p/File::ChangeNotify::Event.3p
+...@man man/man3p/File::ChangeNotify::Watcher.3p
+...@man man/man3p/File::ChangeNotify::Watcher::Default.3p
+...@comment @man man/man3p/File::ChangeNotify::Watcher::Inotify.3p