[TYPO3-core] Caches and Locking
Markus Klein
klein.t3 at mfc-linz.at
Sun Mar 9 14:22:32 CET 2014
Hi!
>
> Hi Markus,
>
> Markus Klein wrote:
>
> > That's the first pitfall. File creation, time checking and all these
> > operations are not atomic (as a block). Hence there's always a way to
> > get this to a race condition. (Actually this is the problem of the 'simple'
> > locking of the Locker class currently.)
>
> IMHO this variant could be extended by write a random (or otherwise
> process
> unique) string into the file, waiting a bit and reading it again. The last writer
> wins here.
>
> Are there any know issues with the 'x' flag for opening the file handle?
> Otherwise this simple lock method looks pretty good already.
???
Giving you a simple example where this already fails horribly.
Process A executes the check for an outdated lock file and is interrupted right after the if check by process B.
Process B does the same, unlinks the file and continues to the foreach to create the new file with fopen().
Now process A has it's turn again and does the unlock (of the newly created file now) and creates the file again.
B and A believe to have the lock now! Awesome!
No matter how you extend this locking "bullsh**" it will never be safe!! (due to the lack of the atomicity of the critical instructions)
Just found something on the web too:
http://technical.allofe.com/contentm/easy_pages/easy_page_view.php?sid=62&page_id=246&blueprint_id=108
>
> Best regards
> --
> Philipp Gampe – PGP-Key 0AD96065 – TYPO3 UG Bonn/Köln Documentation
> – Active contributor TYPO3 CMS
> TYPO3 .... inspiring people to share!
>
Kind regards
Markus
------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
More information about the TYPO3-team-core
mailing list