Re: [SMARTY] conflated cache during crawl

From: Date: Tue, 09 Mar 2004 16:15:48 +0000
Subject: Re: [SMARTY] conflated cache during crawl
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11084@lists.php.net to get a copy of this message
On 3/9/04 5:58 AM, "messju mohr" <messju@lammfellpuschen.de> wrote: > maybe 2 processes write to the same temp-file. Thanks for the insight! I just realized that *i am using a custom plugin* i wrote ( http://smarty.incutio.com/?page=TheCDMLPlugin ) that writes a tempfile that holds a template file for the filemakerpro database. perhaps it is my own tempfiles that are fighting each other for life?! I will rewrite that code to better protect the tempfiles. The tempfile write function in the plugin has *some* locking code which i think should deal with out-of-order file overwrites: ____________________ function write_a_file ($data, $filepath) { // do some checking to see if the text is already written // and only write it again if it has changed //echo $filepath; if($fl = fopen($filepath, 'w+')){ if(flock($fl, LOCK_EX)){ fseek($fl, 0); ftruncate($fl, 0); $stat = fwrite($fl, $data); fflush($fl); flock($fl, LOCK_UN); fclose($fl); } } return $stat; } ____________________ Is this code doing what it should be doing? Is it actually locking the file and preventing overwrites? however, in the wget crawl situation, it may be that once the file is completely written, it is unlocked and then immediately overwritten by another process before the filemaker database can use it in its own template system. > if you can reproduce this behaviour, please try this: yes, i am able to reproduce this behavior by running the wget crawler and then clicking around on the website. > there is a line in smarty/libs/core/core.write_file.php: > > $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid(''); > > change that to > > $_tmp_file = tempnam($_dirname , '_tmp'); > > and rerun you test, and look if the problem remains. > another one to try would be: > > $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('', true); I tried these two lines and still i got conflated caches. this indicates to me that the bug is in my plugin design. > > It would be great if you can test that and tell us if it is of any > help. I think the smarty tempfile code is behaving properly. The problem is most likely in my custom plugin code. More investigating... dan

« previous php.smarty.general (#11084) next »