Robert,
close authlib::FileUnLock($LockFileHandle);
is defiantly an error although sense FileUnLock returned "" it was the
same as:
close "";
which does not seem to produce and error. Thanks for the catch but I
don't think it had any ill side effects.
In
http://perl.plover.com/yak/flock/samples/slide001.html
I learned about locking a lock file and not using LOCK_UN;
Thanks,
Justin
-----Original Message-----
From: Robert Landrum [mailto:suppressed
Sent: Friday, April 13, 2007 3:16 PM
To: Justin Luster
Cc: 'Dondi M. Stroma'; suppressed
Subject: Re: Lock Files - File is permanently locked
Justin Luster wrote:
> Here is an example of a call to OpenFile(). You will notice that I'm
> additionally locking the file itself as well as the lock file (I
figured
> it would not hurt to have both methods):
>
> my $LockFileHandle = authlib::FileLock("udata_" . $strRespNum .
> "_lck.cgi", 1);
>
> #Read restart question name
> my ($DataFileHandle, $blnError) = authlib::OpenFile($strDataFileName,
> "update", 1, 1);
>
> authlib::LockMe($DataFileHandle, 1);
>
> authlib::RestartQNameWrite($DataFileHandle, $strRestartQName);
>
> close $DataFileHandle;
>
> close authlib::FileUnLock($LockFileHandle);
Seems like an awful lot of code...
open(DATAFILE,">$strDataFileName") or die;
flock(DATAFILE,LOCK_EX);
seek(DATAFILE,0,0);
eval {
authlib::RestartQNameWrite(\*DATAFILE,$strRestartQName);
};
flock(DATAFILE,LOCK_UN);
close(DATAFILE);
if($@) {
die $@;
}
Code like that has never failed me on Solaris or Linux. I don't write
W32 code, so maybe it's more complicated than that.
Also,
> close authlib::FileUnLock($LockFileHandle);
That seems like an error waiting to happen, since FileUnLock doesn't
return a file handle.
Rob
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.