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

Reply via email to