Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Will these functions for use with Storable properly lock my file?

by nysus (Parson)
on Aug 03, 2021 at 13:12 UTC ( #11135575=note: print w/replies, xml ) Need Help??


in reply to Will these functions for use with Storable properly lock my file?

After a little testing, it seems to work well. Hard to say for sure with these race conditions. I did make a change to the _retrieve sub to lock the semaphore file even if the data file does not exist:

sub _retrieve { my $data_file = 'data/plugin_portfolio'; my $lock = $data_file . '.lck'; open (LOCK, "> $lock") or die "Can't open lock file"; flock(LOCK, LOCK_EX); return 0 if !-f $data_file; retrieve $data_file; }

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

  • Comment on Re: Will these functions for use with Storable properly lock my file?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2021-10-23 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?