The following code includes a recursive call to File::NFSLock::new. However,
there is no localization of _FH handle within the new function :
188 ### If there was at least one stale lock discovered...
189 if (@dead) {
190 # Lock lock_file to avoid a race condition.
191 local $LOCK_EXTENSION = ".shared";
192 my $lock = new File::NFSLock {
193 file => $self->{lock_file},
194 lock_type => LOCK_EX,
195 blocking_timeout => 62,
196 stale_lock_timeout => 60,
197 };
198
199 ### Rescan in case lock contents were modified between time stale lock
200 ### was discovered and lockfile lock was acquired.
201 seek (_FH, 0, 0);
Therefore, if the recursive call to the new succeeds, the _FH handle that was
opened within the recursive call is closed. The result is the following error:
seek() on closed filehandle _FH at /opt/perl/5.8.5/lib/site_perl/5.8.5/File/NFSLock.pm line 201.
readline() on closed filehandle _FH at /opt/perl/5.8.5/lib/site_perl/5.8.5/File/NFSLock.pm line 203.
The fix will be add a local declaration:
local *_FH;
before the open in the new function:
161 ### If lock exists and is readable, see who is mooching on the lock
162
163 if ( -e $self->{lock_file} &&
164 open (_FH,"+<$self->{lock_file}") ){
165
The above error results causes the (@dead) part of the code not functioning
as expected - thus not recovering from stale locks.