httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guenter Knauf <fua...@apache.org>
Subject Re: svn commit: r1466669 - /httpd/httpd/branches/2.4.x/STATUS
Date Fri, 12 Apr 2013 19:01:22 GMT
On 11.04.2013 12:25, Guenter Knauf wrote:
> well, another possible fix would be this one:
>
> Index: modules/lua/lua_request.c
> ===================================================================
> --- modules/lua/lua_request.c    (revision 1466743)
> +++ modules/lua/lua_request.c    (working copy)
> @@ -1204,19 +1204,19 @@
>       luaL_checktype(L, 2, LUA_TSTRING);
>       r = ap_lua_check_request_rec(L, 1);
>       filename = lua_tostring(L, 2);
> -    if (apr_stat(&file_info, filename, APR_FINFO_NORM, r->pool) == OK) {
> +    if (apr_stat(&file_info, filename, APR_FINFO_MIN, r->pool) == OK) {
>           lua_newtable(L);
>
>           lua_pushstring(L, "mtime");
> -        lua_pushinteger(L, (ptrdiff_t)(file_info.mtime / 1000000));
> +        lua_pushnumber(L, file_info.mtime);
>           lua_settable(L, -3);
>
>           lua_pushstring(L, "atime");
> -        lua_pushinteger(L, (ptrdiff_t)(file_info.atime / 1000000));
> +        lua_pushnumber(L, file_info.atime);
>           lua_settable(L, -3);
>
>           lua_pushstring(L, "ctime");
> -        lua_pushinteger(L, (ptrdiff_t)(file_info.ctime / 1000000));
> +        lua_pushnumber(L, file_info.ctime);
>           lua_settable(L, -3);
>
>           lua_pushstring(L, "size");
>
> this way we bring the higher resolution of the time values into Lua;
> however I've not yet checked if there are platforms which really provide
> mtime/atime/ctime with a better resolution than 1 second;
> if there are then it makes probably sense for the above patch, and then
> do the divide if needed within the Lua scripts like:
>
> local mtime = os.date(fmt, math.floor(info.mtime / 1000000))
> r:puts( ("%s was last modified at: %s\n"):format(r.filename, mtime) )
>
> since there might be usage cases for the time values other than feeding
> os.date() for displaying, f.e. a simple compare; and one second is long ;-)
>
> comments welcome!
no comment so far; I searched a bit more about this, and found:
http://en.wikipedia.org/wiki/Stat_%28system_call%29#Granularity_of_mtime.2C_etc.

therefore I will apply above patch to get the finer granularity into 
mod_lua.

Gün.




Mime
View raw message