Skip Menu |

This queue is for tickets about the File-ChangeNotify CPAN distribution.

Report information
The Basics
Id: 64364
Status: resolved
Priority: 0/
Queue: File-ChangeNotify

People
Owner: Nobody in particular
Requestors: ports [...] andreasvoegele.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.19
Fixed in: 0.20



Subject: Handling closed file handles in KQueue.pm
Hi Dave, when running the File::ChangeNotify module's tests on OpenBSD, testing a directory with circular symlinks fails since an undefined file descriptor is passed to EV_SET() in _watch_file() in KQueue.pm. _watch_file() tries to open a file, checks the file handle, and then calls EV_SET() with the file handle's file descriptor: open my $fh, '<', $file or warn "Can't open '$file': $!"; return unless $fh; $self->_kqueue->EV_SET( fileno($fh), [...] I suggest to also check whether the file handle's file descriptor is defined. For example: open my $fh, '<', $file or warn "Can't open '$file': $!"; return unless $fh && defined fileno($fh); Description of fileno() in perlfunc(1): "fileno FILEHANDLE Returns the file descriptor for a filehandle, or undefined if the filehandle is not open. [...]" Regards, Andreas
Subject: patch-lib_File_ChangeNotify_Watcher_KQueue_pm.txt
$OpenBSD$ --- lib/File/ChangeNotify/Watcher/KQueue.pm.orig Sun Oct 17 22:00:14 2010 +++ lib/File/ChangeNotify/Watcher/KQueue.pm Fri Dec 31 16:39:44 2010 @@ -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)
From: ports [...] andreasvoegele.com
Here's an updated patch that adds information on how to check and raise the open file limits on OpenBSD.
Subject: patch-lib_File_ChangeNotify_Watcher_KQueue_pm.txt
$OpenBSD$ --- lib/File/ChangeNotify/Watcher/KQueue.pm.orig Sun Oct 17 22:00:14 2010 +++ lib/File/ChangeNotify/Watcher/KQueue.pm Sat Jan 1 07:55:18 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)> for +details. =head1 SUPPORT