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.629 2006/12/05 15:51:24 grubba Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.630 2007/01/03 12:41:19 grubba 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:208:   {    return current_connections;   }      // It's nice to have the name when the rest of __INIT executes.   string name = roxen->bootstrap_info->get();      class DataCache   {    static typedef array(string|mapping(string:mixed))|string| -  function(string, RequestID:string) EntryType; +  function(string, RequestID:string|int) EntryType;       mapping(string:EntryType) cache = ([]);       int current_size;    int max_size;    int max_file_size;       int hits, misses;       void flush()
Roxen.git/server/base_server/configuration.pike:292:    // Avoid spoofing if key_frag happens to contain "\0\0".    key_frag = replace (key_frag, "\0", "\0\1");    else key_frag = "";    key_prefix += "\0\0" + key_frag;    }    }       //! Clear ~1/10th of the cache.    static void clear_some_cache()    { -  // FIXME: Use random(cache) instead to avoid the indices() call. +     array(string) q = indices(cache);    if(!sizeof(q))    {    current_size=0;    return;    }       // The following code should be ~O(n * log(n)).    sort(q);    for(int i = 0; i < sizeof(q)/10; i++) {
Roxen.git/server/base_server/configuration.pike:322:    }    }       void set(string url, string data, mapping meta, int expire, RequestID id)    {    if( strlen( data ) > max_file_size ) return;       string key = url;       foreach(id->misc->vary_cb_order || ({}), -  string|function(string, RequestID: string) vary_cb) { +  string|function(string, RequestID: string|int) vary_cb) {    array(string|mapping(string:mixed))|string| -  function(string, RequestID:string) old = cache[key]; +  function(string, RequestID:string|int) old = cache[key];    if (old && (old != vary_cb)) {    // FIXME: Warn?    low_expire_entry(key);    }    cache[key] = vary_cb;    -  string|array(string) key_frag; +  string key_frag;    if (stringp(vary_cb)) { -  key_frag = id->request_headers[vary_cb]; +  string|array(string) header = id->request_headers[vary_cb]; +  if (arrayp(header)) key_frag = header * ","; +  else key_frag = header;    } else { -  key_frag = vary_cb(url, id); +  int|string frag = vary_cb(url, id); +  if (intp(frag) && frag) { +  key_frag = frag->digits(256); +  } else { +  key_frag = 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) {
Roxen.git/server/base_server/configuration.pike:365:    // FIXME: This could lead to lots and lots of call outs.. :P    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)    {    array(string|mapping(string:mixed))|string| -  function(string, RequestID:string) res; +  function(string, RequestID:string|int) res;    string key = url;    while(1) {    id->misc->protcache_cost++;    if (arrayp(res = cache[key])) {    hits++;    return [array(string|mapping(string:mixed))]res;    }    if (!res) {    misses++;    return UNDEFINED;    }    -  string|array(string) key_frag; +  string key_frag;    if (stringp(res)) { -  key_frag = id->request_headers[res]; +  string|array(string) header = id->request_headers[res]; +  if (arrayp(header)) key_frag = header * ","; +  else key_frag = header;    } else { -  key_frag = res(url, id); +  int|string frag = res(url, id); +  if (intp(frag) && frag) { +  key_frag = frag->digits(256); +  } else { +  key_frag = 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( )    {
Roxen.git/server/base_server/configuration.pike:612:    string|void myext )   {    array(string)|string tmp;    if(!types_fun)    return to?({ "application/octet-stream", 0 }):"application/octet-stream";       string ext = lower_case(myext || Roxen.extension(file));       if(tmp = types_fun(ext))    { -  mixed tmp2,nx; +     // FIXME: Ought to support several levels of "strip".    if (tmp[0] == "strip")    { -  tmp2=file/"."; +  array(string) tmp2 = file/"."; +  string nx;    if (sizeof(tmp2) > 2) -  nx=tmp2[-2]; -  if (nx && (tmp2 = types_fun(nx))) -  tmp[0] = tmp2[0]; -  else if (tmp2 = types_fun("default")) -  tmp[0] = tmp2[0]; -  else -  tmp[0] = "application/octet-stream"; +  nx = lower_case(tmp2[-2]); +  tmp[0] = (nx && types_fun(nx)) || types_fun("default") || +  "application/octet-stream";    }    } else if (!(tmp = types_fun("default"))) {    tmp = ({ "application/octet-stream", 0 });    }    return to?tmp:tmp[0];   }      array (RoxenModule) get_providers(string provides)   //! Returns an array with all provider modules that provides "provides".   {