Re: [SMARTY-DEV] Is there a "race condition"?

From: Date: Fri, 07 Feb 2003 14:21:26 +0000
Subject: Re: [SMARTY-DEV] Is there a "race condition"?
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-669@lists.php.net to get a copy of this message
On Fri, Feb 07, 2003 at 02:01:02PM +0300, Konstantin wrote: > Looking into Smarty (2.3.1) code, I see that compiled > template update is not atomic (fopen-flock-fwrite-fclose-touch) > and there is no flock before include of it. Is there flock in PHP > include code? no. unfortunately there is no implicit flock involved in include() . > Theoretically, it seems to me that one process can include > compiled template just after another process discards > its content in fopen (for writing). It means, one request > will receive empty output. > It is possible that parallel processes will compile a template > (in the time between checking mtime and touching). It's not > very bad, but some waste of performance. > We are using PHPA accelerator, and it seems possible that empty > compiled template can be cached. (It really happens with another > caching systems or ftp file uploading). > > I'm not the perfect programmer. Can anybody investigate it? > > Anyway, if I'm right, the solution seems simple: write to a file > with temporary name and rename it after touching this sounds like a good idea to me. since this additional rename() is only involved when compiling the template and not on every include the overhead should be bearable. > (on linux renames are atomic). and on other system the situation wouldn't get worse, than it is now, i think. messju > WBR, Konstantin A. Pelepelin

« previous php.smarty.dev (#669) next »