ccache not loading or storing cache files
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 19 Dec 2012 00:35:30 +0000 (00:35 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 19 Dec 2012 00:35:30 +0000 (00:35 +0000)
I've noticed that there is nothing in my /tmp/luci-modulecache
directory. Digging into it it looks like because both the expected uid
and mode of the files doesn't match, so for security reasons they're
long being loaded or saved by ccache.lua (from the luci-lib-core
package). I'm not sure how far back this has been broken but I it
appears to have been quite some time, possibly years?

I've included a patch which updates the checks to use the right newer
function name / structure name. It decreases page load times by about
10-15% on my bcm2708 (raspberrypi). I can create a ticket if you'd
prefer. The patch is against the luci-0.11 branch but should apply to
trunk as well.

Signed-off-by: Bryan Mayland <bmayland@leoninedev.com>
libs/core/luasrc/ccache.lua

index c9771af..56ccbc3 100644 (file)
@@ -37,7 +37,7 @@ function cache_enable(cachepath, mode)
        mode = mode or "r--r--r--"
 
        local loader = package.loaders[2]
        mode = mode or "r--r--r--"
 
        local loader = package.loaders[2]
-       local uid    = nixio.getpid("uid")
+       local uid    = nixio.getuid()
 
        if not fs.stat(cachepath) then
                fs.mkdir(cachepath)
 
        if not fs.stat(cachepath) then
                fs.mkdir(cachepath)
@@ -53,7 +53,7 @@ function cache_enable(cachepath, mode)
 
        local function _load_sane(file)
                local stat = fs.stat(file)
 
        local function _load_sane(file)
                local stat = fs.stat(file)
-               if stat and stat.uid == uid and stat.mode == mode then
+               if stat and stat.uid == uid and stat.modestr == mode then
                        return loadfile(file)
                end
        end
                        return loadfile(file)
                end
        end