Locking of open tellico file?

Steven W. Orr steveo at syslang.net
Mon Apr 16 08:27:01 MDT 2007


On Sunday, Apr 15th 2007 at 23:13 -0700, quoth Robby Stephenson:

=>On Saturday 14 April 2007, Norbert Nemec wrote:
=>> over and over again, I happened to accidentally open two instances of
=>> tellico in parallel leading to the loss of changes done in one of them,
=>> when I save from the other. Could the file be locked at opening as it is
=>> done in many other programs?
=>
=>I guess so. I'm not sure how. Once all the data is read, the file is closed. 
=>If I created a lock file or wrote some setting, then after crashes, you run 
=>into that old Netscape problem where the dialog comes up saying "delete the 
=>lock file before running"
=>
=>Robby

If you really want to do filelocking I'd recommend not doing it that way. 
You have two attack approaches. You probably don't want to do advisory 
filelocking because the format of a file is open source and it would only 
be effective in an environment where you're guaranteed that all other 
accessors would be cooperating. (I don't know how many other people are 
writing tellico files yet, but...) The mandatory side using 
fcntl()/lockf() would do the trick but you're right in that the file would 
have to be kept open, which would require some sort of

unlink the old one
unlock and close the old one
write a new file

to make it all work.


-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the tellico-users mailing list