|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-05-30 07:40 UTC] swen dot thuemmler at telefonica dot de
Description:
------------
APC uses the inode number as a cache key and uses mtime to check,
wether the cache content is still valid.
I see a possible problem with this: apc does not know when a file gets
deleted. So a file might get deleted and later a new file created with
the same inode and possibly a smaller mtime (Smarty for instance
creates its php files with the mtime of the originating template). Now
a request for this file will get the old content of the deleted file, not
the content of the new one.
A possible solution: set key.mtime to the max of (mtime, ctime), see
enclosed patch.
Comments?
diff -u -r3.55 apc_cache.c
--- apc_cache.c 29 Mar 2004 17:18:11 -0000 3.55
+++ apc_cache.c 30 May 2004 11:47:10 -0000
@@ -346,7 +346,7 @@
key->device = buf.st_dev;
key->inode = buf.st_ino;
- key->mtime = buf.st_mtime;
+ key->mtime = (buf.st_ctime > buf.st_mtime) ? buf.st_ctime: buf.st_mtime;
return 1;
}
/* }}} */
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 10:00:02 2025 UTC |
Hmm, this still leaves the case when a file gets deleted and a new file with same inode but different - possibly smaller - mtime gets created. APC would not detect this case. Simple but IMHO effetive solution: check whether mtime changes, not only whether it increases. Comments? Regards, Swen diff -u -r3.71 apc_cache.c --- apc_cache.c 14 Sep 2004 17:34:28 -0000 3.71 +++ apc_cache.c 15 Sep 2004 07:54:09 -0000 @@ -331,7 +331,7 @@ while (*slot) { if (key_equals((*slot)->key.data.file, key.data.file)) { /* If existing slot for the same device+inode is older, remove it and insert the new version */ - if ((*slot)->key.mtime < key.mtime) { + if ((*slot)->key.mtime != key.mtime) { remove_slot(cache, slot); break; } @@ -412,7 +412,7 @@ while (*slot) { if (key_equals((*slot)->key.data.file, key.data.file)) { - if ((*slot)->key.mtime < key.mtime) { + if ((*slot)->key.mtime != key.mtime) { remove_slot(cache, slot); break; }