Re: [SMARTY-DEV] On caching mechanics
| From: | messju mohr | Date: | Thu, 04 Sep 2003 13:38:16 +0000 |
| Subject: | Re: [SMARTY-DEV] On caching mechanics | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1856@lists.php.net to get a copy of this message | ||
On Wed, Sep 03, 2003 at 11:10:19AM +0400, Konstantin wrote:
> > > Imagine that first process creates directory for cache
> > > file, at this moment second process makes a sort of
> > > clear_all_cache(), which removes directory structure,
> > > and then first process cannot open file for writing.
> I don't know. I know there was a theoretical problem with
> locking files, and that is why temporary files used in
> smarty_core_write_file(). Removed directories is another
> problem.
and there was a race condition in smarty_core_create_structure() that
i fixed. when called two times in parallel
smarty_core_create_structure abortetd with an error because it
couldn't mkdir() (done by the other one). i think that's what boot
remembered.
but this here is another race condition.
> > It seems to me that its more of a
> > logging issue than an actual problem. Perhaps @ will
> > help?
> Well, problem writing cache file is really not a problem,
> cache will be regenerated on next request (but on a not
> properly set up project this may be permanent problem, so
> at development time warning may be useful).
that's the reason why i wouldn't want to lower the error-level as you
suggest below. with $smarty->debugging=false (the default) notices a
not displayed regardless of the error-reporting setting. a newbie
installing smarty would be pulling his hair out debbuging his/her
cache_dir-settings.
unfortunately i don't have a graceful solution at hand. i think
implementing a mutex with multiple readers (cache_write_file) and
single writer (clear_all_cache) would be overkill for this rare case.
of course i'm open to suggestions regarding this.
for now i'm afraid you have to live with this inconvinience or
implement you own mutex around display (which is of course not as
efficient as putting that directly into write_file). another solution
would be using 2 cache-dirs and (hot-)swapping them for clearing the
cache.
greetings
messju
> The same
> function is used in smarty_core_write_compiled_resource(),
> and problem writing it is really a problem for this
> display() request. But this is more rare, since compiled
> templates dir never gets cleared in normal work flow.
>
> > > Warning: Smarty error: problem writing temporary file
> I suppose to change this error level to E_USER_NOTICE.
>
>
> Konstantin A. Pelepelin