i2mc - No you misunderstood...
When the file is updated. ie READ records -> update -> WRITE records, it IS locked... (There is a LOCK around the whole procedure)
But during this people can READ the data. Under tests the this can result in an empty read. So, this does NOT explain my half...
i2mc - I think you're wrong...
You say the fact I'm reading the file while others may be writing it could screw it up.
I've done a couple of tests this does not seem to be the case. I've got two browser windows. One writing the file (with a sleep statement between each PRINT), and another...
I've just had a thought...
When people update the file I do lock it... But people can view data from the file (ie: not update it) at ANY time. There is NO locking around this reading.
If someone is writing to the file (eg: file.txt) using:-
open(DF,">file.txt");
foreach $record...
I check my OPEN statements for errors, and I lock during all updates using calls to the following subs:-
#--------------
# Locking on
# Try for 14 secs, else overwrite it - Makes crash proof!
#--------------
sub lock_on{
$lock_file=$_[0];
for($i=1;$i<=14;$i++){if(-e $lock_file){sleep...
No, I'm simply doing something along the lines of...
open(DF,"file.txt");
while($data_line=<DF>){push(@database_rows, $data_line);}
close DF;
I Adjust the records in DATABASE_ROWS and then...
open(DF,">file.txt");
foreach $record (@database_rows){print DF $record;}
close...
I have a simple program that basically reads in say 15,000 lines and prints them back out again (eg: "PRINT DF $rec" in a loop)...
Over 99% of the time it works an absolute treat, but every now and then it seems to go wrong and only manage to right back a fraction of the records (eg...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.