Locking of open tellico file?

Norbet Namec Norbert.Nemec.List at gmx.de
Tue Apr 17 01:49:06 MDT 2007


I'm not an expert, so I just had a look at
http://en.wikipedia.org/wiki/File_locking
which gives a good general overview.

It seems, there is no perfectly portable way of file locking. Still, I would say that a solution that works for most systems is better than no locking at all.

Mandatory locking should not be necessary. Most users will use only tellico to access the file and whoever decides to use some other badly written program that ignores the lock should not blame tellico for that.

flock or fnctl should both work, but there also is a class QtLockedFile that might do the job easier and more portable. KDE might also contain some mechanism, but I don't know that.

In any case, locking will imply keeping the file opened, but that only makes sense. Simply rename to a .tc~ backup file, close it and write a new one when saving.


-------- Original-Nachricht --------
Datum: Mon, 16 Apr 2007 10:27:01 -0400 (EDT)
Von: "Steven W. Orr" <steveo at syslang.net>
An: Robby Stephenson <robby at periapsis.org>
CC: tellico-users at forge.novell.com
Betreff: Re: Locking of open tellico file?

> 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
> _______________________________________________
> tellico-users mailing list
> tellico-users at forge.novell.com
> http://forge.novell.com/mailman/listinfo/tellico-users

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail



More information about the tellico-users mailing list