in reply to Re: How to apply flock
in thread How to apply flock
The Berkeley DB mechanisms take care of any potential data corruption.
In the example below, run #1 and then #2 while #1 is still running (preferably in 2 separate shells -- simultaneous)
When you first run #1, and then #2 ( while #1 is still running), #2 will yield# 1 perl -MFcntl -MDB_File -e"tie%a,'DB_File','rat.test',O_CREAT|O_RDWR or + die $!;for(1..1_000){select undef,undef,undef,.01;$a{a}++;}" # 2 perl -MFcntl -MDB_File -e"tie%a,'DB_File','rat.test',O_RDONLY or die $ +!;warn $a{a}"
In my programs, I freely tie a DB_File for O_RDONLY, but for O_RDWR, I use a flocking mechanism like DB_File::Lock.
MJD says you can't just make shit up and expect the computer to know what you mean, retardo! ** The Third rule of perl club is a statement of fact: pod is sexy. |
|
---|