Roxen.git / server / etc / modules / VFS.pmod

version» Context lines:

Roxen.git/server/etc/modules/VFS.pmod:60:    if( res && last_mtime )    {    Stat s = stat( file, id );    if( s && ((mtime=s[ST_MTIME])<=last_mtime) )    return ({ mtime, res });    res=0;    }    }    if( !res )    res = c->try_get_file( file, id ); -  if( cache ) +  // FIXME: Support negative caching. +  if( cache && res )    cache_set( ck, file, res );    if( last_mtime && res )    {    if( !mtime )    {    Stat s = stat( file, id );    mtime = s && s[ST_MTIME];    }    return ({ mtime, res });    }    return res;   }    -  + protected cache.CacheManagerPrefs extend_entries_cache_prefs = +  cache.CacheManagerPrefs(1); +    array(string) find_above_read( string above,    string name,    RequestID id,    string|void cache,    int|void do_mtime )   //! Operates more or less like a combination of find_above and read.   //! The major difference from calling read( find_above( above, name,   //! id, cache ), id, cache, last_mtime ) is that this function does   //! automatic mtime handling if you specify do_mtime. Also, it calls   //! find_above repeatedly until it finds a file it can actually read.
Roxen.git/server/etc/modules/VFS.pmod:103: Inside #if defined(HTACCESS_DEBUG)
   werror("find_above_read(%O, %O, %O, %O, %O)...\n",    above, name, id, cache, do_mtime);   #endif /* HTACCESS_DEBUG */    while( strlen( above ) )    {    int last_mtime;    string ck;    above = find_above( above, name, id, (cache&&cache+":above") );    if( !above )    return 0; -  if( do_mtime ) -  last_mtime = cache_lookup( (ck=cache+":mtime:"+id->conf->name+ -  ":"+id->misc->host), above )||-1; +  if( do_mtime ) { +  ck = cache+":mtime:"+id->conf->name+":"+id->misc->host; +  predef::cache.cache_register(ck, UNDEFINED, extend_entries_cache_prefs); +  last_mtime = cache_lookup( ck, above )||-1; +  }       if( string|array data = read( above, id, !!cache, last_mtime ) )    {    if( arrayp( data ) )    { -  +  if (do_mtime)    cache_set( ck, above, data[0]||-1 );    return ({ above, data[1], data[0] });    }    return ({ above, data, 0 });    } -  +  if (above == "/" + name) break; + #ifdef HTACCESS_DEBUG +  werror("above: %O ==> %O\n", above, combine_path(above, "..")); + #endif /* HTACCESS_DEBUG */    above = combine_path( above, ".." );    } -  + #ifdef HTACCESS_DEBUG +  werror("find_above_read: Failed.\n"); + #endif /* HTACCESS_DEBUG */    return 0;   }         string find_above( string above,    string name,    RequestID id,    string|void cache )   //! Return the filename of the first file named @[name] _above_ the   //! specified path. As an example, if @[name] is .htaccess, and above
Roxen.git/server/etc/modules/VFS.pmod:148:   //! If @[cache] is specified, the result will be cached under the name   //! specified. No stat(2) validation is done.   {    string res;    string ck;       if( above[-1] != '/' ) above = combine_path( above, "../" );       if( cache ) res = cache_lookup( (ck=cache+":"+    id->conf->name+":"+id->misc->host), above ); -  if( res ) return res; +     -  +  if (res) return stringp (res) ? res : 0; +     // No luck. Try to locate the file in the VFS.    array(string) segments = ({""})+(above/"/"-({""}));    for( int i=sizeof( segments )-1; i>=0 ; i-- )    {    string subvpath = combine_path("/"+segments[..i]*"/", name);    if( Stat st = stat( subvpath, id ) )    {    // CONSIDER: Assure that the file can be opened as well?    res = subvpath;    break;    }    } -  if( res && cache ) -  return cache_set( ck, above, res ); +  cache_set( ck, above, res || -1, res ? 60 : 5);    return res;   }