lighttpd forum XCache > xcache.stat doesn't work

Posted by Gianluigi Tiesi (Guest)
on 03.04.2007 07:23
I've installed xcache 1.2.0, it works fine pages are correctly cached,
but changes on files are not detected, cached pages never expire
even if the source is changed.
I've tried to enable/disable xcache.stat without success.
Running on debian sarge
gcc version 3.3.5 (Debian 1:3.3.5-13)
mod_php: PHP 4.3.10
apache 1.3.33

I've mounted the fs with noatime, it shouldn't make difference
xcache should rely on mtime

need other infos?

xcache.ini

; xcache
[xcache-common]
;; install as zend extension (recommended), normally 
"$extension_dir/xcache.so"
zend_extension = /usr/lib/php4/20020429/xcache.so
; zend_extension_ts = 
/usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so
;; For windows users, replace xcache.so with php_xcache.dll
zend_extension_ts = /usr/lib/php4/20020429/xcache.so
;; or install as extension, make sure your extension_dir setting is 
correct
; extension = xcache.so
;; or win32:
; extension = php_xcache.dll

[xcache.admin]
xcache.admin.user = "mOo"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = ""

[xcache]
; ini only settings, all the values here is default unless explained

; select low level shm/allocator scheme implemenation
xcache.shm_scheme =        "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size > 0) and your system mmap 
allows
xcache.size  =                64M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 2
; just a hash hints, you can always store count(items) > slots
xcache.slots =                8K
; ttl of the cache item, 0=forever
xcache.ttl   =                 0
; interval of gc scanning expired items, 0=no scan, other values is in 
seconds
xcache.gc_interval =           0

; same as aboves but for variable cache
xcache.var_size  =            32M
xcache.var_count =             1
xcache.var_slots =            8K
; default ttl
xcache.var_ttl   =             0
xcache.var_maxttl   =          0
xcache.var_gc_interval =     300

xcache.test =                On
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on 
ReadonlyProtection
; 2 group of php won't share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path =    "/dev/zero"


; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it's writable by php (without checking open_basedir)
xcache.coredump_directory =   ""

; per request settings
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =            On
Posted by Gianluigi Tiesi (Guest)
on 14.04.2007 01:15
no replies?
Posted by moo XCache
on 15.04.2007 04:26
Gianluigi Tiesi wrote:
> no replies?

sorry, i can't think of any possibility why this is happening
Posted by Gianluigi Tiesi (Guest)
on 18.04.2007 16:00
moo XCache wrote:
> Gianluigi Tiesi wrote:
>> no replies?
> 
> sorry, i can't think of any possibility why this is happening

I'll have anyway benefit without cacher, I mean the opcodes are anyway 
cached right?
Posted by Gianluigi Tiesi (Guest)
on 18.04.2007 16:18
I've found a workaround, by googling a bit I've discovered that 
sapi_get_stat() is often unrealable and I've made a real stat.


--- xcache.c.orig       2007-04-18 18:02:23.339627328 +0200
+++ xcache.c    2007-04-18 18:13:17.716146976 +0200
@@ -712,8 +712,9 @@

        if (XG(stat)) {
                if (strcmp(SG(request_info).path_translated, filename) 
== 0) {
-                       /* sapi has already done this stat() for us */
-                       pbuf = sapi_get_stat(TSRMLS_C);
+                       /* sapi stat is unrealable */
+                       stat(filename, &buf);
+                       pbuf = &buf;
                        if (pbuf) {
                                goto stat_done;
                        }
Posted by moo XCache
on 19.04.2007 05:48
okay, this makes sense, we might need a version check or whatever.
Posted by Walter Tross (Guest)
on 29.04.2008 17:50
Gianluigi Tiesi wrote:
> I've found a workaround, by googling a bit I've discovered that 
> sapi_get_stat() is often unrealable and I've made a real stat.
> 
> 
> --- xcache.c.orig       2007-04-18 18:02:23.339627328 +0200
> +++ xcache.c    2007-04-18 18:13:17.716146976 +0200
> @@ -712,8 +712,9 @@
> 
>         if (XG(stat)) {
>                 if (strcmp(SG(request_info).path_translated, filename) 
> == 0) {
> -                       /* sapi has already done this stat() for us */
> -                       pbuf = sapi_get_stat(TSRMLS_C);
> +                       /* sapi stat is unrealable */
> +                       stat(filename, &buf);
> +                       pbuf = &buf;
>                         if (pbuf) {
>                                 goto stat_done;
>                         }

I stumbled upon the above code while looking for something else, and 
noticed that pbuf will never evaluate to false once the patch is 
applied, since it will always be assigned the address of buf. In other 
words, the patch behaves like the original code only as long as the stat 
does not fail.
Posted by moo XCache
on 05.05.2008 12:03
>                 if (strcmp(SG(request_info).path_translated, filename) 
> == 0) {
> -                       /* sapi has already done this stat() for us */
> -                       pbuf = sapi_get_stat(TSRMLS_C);
> +                       /* sapi stat is unrealable */
> +                       stat(filename, &buf);
> +                       pbuf = &buf;
>                         if (pbuf) {
>                                 goto stat_done;
>                         }

ok, what version of php and which sapi are you using