Roxen.git / server / base_server / configuration.pike

version» Context lines:

Roxen.git/server/base_server/configuration.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //      // @appears Configuration   //! A site's main configuration    - constant cvs_version = "$Id: configuration.pike,v 1.643 2007/12/21 16:01:06 grubba Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.644 2008/01/09 16:40:43 mast Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>   #include <request_trace.h>   #include <timers.h>      #define CATCH(P,X) do{mixed e;if(e=catch{X;})report_error("While "+P+"\n"+describe_backtrace(e));}while(0)      // --- Locale defines ---   //<locale-token project="roxen_start"> LOC_S </locale-token>
Roxen.git/server/base_server/configuration.pike:319:    if (!q[r]) continue;    if (!has_prefix(q[r], key_prefix)) break;    really_low_expire_entry(q[r]);    q[r] = 0;    }    }    }       void set(string url, string data, mapping meta, int expire, RequestID id)    { -  if( strlen( data ) > max_file_size ) return; +  if( strlen( data ) > max_file_size ) { +  SIMPLE_TRACE_ENTER (this, "Result of size %d is too large " +  "to store in the protocol cache (limit %d)", +  sizeof (data), max_file_size); +  SIMPLE_TRACE_LEAVE (""); +  return; +  }    -  +  SIMPLE_TRACE_ENTER (this, "Storing result of size %d in the protocol cache " +  "using key %O (expire in %ds)", +  sizeof (data), url, expire);    string key = url;       foreach(id->misc->vary_cb_order || ({}),    string|function(string, RequestID: string|int) vary_cb) {    array(string|mapping(string:mixed))|string|    function(string, RequestID:string|int) old = cache[key];    if (old && (old != vary_cb)) { -  // FIXME: Warn? +  SIMPLE_TRACE_ENTER (this, "Registering vary cb %O - conflicts with " +  "existing entry %s, old entry expired", +  vary_cb, +  (arrayp (old) ? "of size " + sizeof (old[0]) : +  sprintf ("%O", old)));    low_expire_entry(key); -  +  SIMPLE_TRACE_LEAVE ("");    }    cache[key] = vary_cb;    -  +  SIMPLE_TRACE_ENTER (this, "Registering vary cb %O", vary_cb); +     string key_frag;    if (stringp(vary_cb)) {    string|array(string) header = id->request_headers[vary_cb];    if (arrayp(header)) key_frag = header * ",";    else key_frag = header;    } else {    int|string frag = vary_cb(url, id);    if (intp(frag) && frag) {    key_frag = frag->digits(256);    } else {    key_frag = frag;    }    } -  +  +  SIMPLE_TRACE_LEAVE ("Vary cb resolved to key fragment %O", +  key_frag || ""); +     if (key_frag)    // Avoid spoofing if key_frag happens to contain "\0\0".    key_frag = replace (key_frag, "\0", "\0\1");    else key_frag = "";    key += "\0\0" + key_frag;    }       array(string|mapping(string:mixed))|string|    function(string, RequestID:string) old = cache[key];    if (old) { -  // FIXME: Warn? +  SIMPLE_TRACE_LEAVE ("Entry conflicts with existing entry %s, " +  "old entry expired", +  (arrayp (old) ? "of size " + sizeof (old[0]) : +  sprintf ("%O", old)));    low_expire_entry(key);    } -  +  else +  SIMPLE_TRACE_LEAVE ("");       current_size += strlen( data );    cache[key] = ({ data, meta });       // Only the actual cache entry is expired.    // FIXME: This could lead to lots and lots of call outs.. :P    meta->co_handle = call_out(really_low_expire_entry, expire, key);    int n;    while( (current_size > max_size) && (n++<10))    clear_some_cache();    }       array(string|mapping(string:mixed)) get(string url, RequestID id)    { -  +  SIMPLE_TRACE_ENTER (this, "Looking up entry for %O in the protocol cache", +  url); +     array(string|mapping(string:mixed))|string|    function(string, RequestID:string|int) res;    string key = url;    while(1) {    id->misc->protcache_cost++;    if (arrayp(res = cache[key])) {    hits++; -  +  SIMPLE_TRACE_LEAVE ("Found entry of size %d", sizeof (res[0]));    return [array(string|mapping(string:mixed))]res;    }    if (!res) {    misses++; -  +  SIMPLE_TRACE_LEAVE ("Found no entry");    return UNDEFINED;    }    -  +  SIMPLE_TRACE_ENTER (this, "Found vary cb %O", res); +     string key_frag;    if (stringp(res)) {    string|array(string) header = id->request_headers[res];    if (arrayp(header)) key_frag = header * ",";    else key_frag = header;    } else {    int|string frag = res(url, id);    if (intp(frag) && frag) {    key_frag = frag->digits(256);    } else {    key_frag = frag;    }    } -  +  +  SIMPLE_TRACE_LEAVE ("Vary cb resolved to key fragment %O", +  key_frag || ""); +     if (key_frag)    // Avoid spoofing if key_frag happens to contain "\0\0".    key_frag = replace (key_frag, "\0", "\0\1");    else key_frag = "";    key += "\0\0" + key_frag;    };    }       void init_from_variables( )    {