[Interest] QFileSystemWatcher malfunctioning

Jason H scorp1us at yahoo.com
Thu Jan 12 22:20:52 CET 2012


MD5 summing & comparing would be the only way, and even then another program would be indistinguishable if it made the same changes. However that corner case should be a moot point.



________________________________
 From: Bo Thorsen <bo at fioniasoftware.dk>
To: interest at qt-project.org 
Sent: Thursday, January 12, 2012 4:13 PM
Subject: Re: [Interest] QFileSystemWatcher malfunctioning
 
Den 12-01-2012 14:56, Atlant Schmidt skrev:
> All:
>
>> With this class you just do this:
>>
>> {
>>      SignalBlocker blocker(watcher);
>>      modifyTheFile();
>> }
>
>    It seems to me that there's a race condition here.
>    Unless you're taking steps to deliberately lock-out
>    other processes from modifying the file, then they
>    could slip in immediately before or after you modify
>    the file and you would never know they'd been there
>    because you have the signal blocked.

True. But if you modify the file, you have a race condition anyway, 
since you don't know if that was done before or after you do this. You 
might not get the modified signal before you change the file contents.

If you're after a fool proof system, don't block the filewatcher and 
read it after your own changes, and check that the contents hadn't been 
changed before you do it. Or use a database.

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120112/7733bd4d/attachment.html>


More information about the Interest mailing list