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.637 2007/08/06 07:14:47 noring Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.638 2007/09/10 11:59:58 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:232:    cache = ([]);   #endif    }       // Expire a single entry.    static void really_low_expire_entry(string key)    {    EntryType e = m_delete(cache, key);    if (arrayp(e)) {    current_size -= sizeof(e[0]); +  if (e[1]->co_handle) { +  remove_call_out(e[1]->co_handle);    }    } -  +  }       // NOTE: Avoid using this function if possible! O(n)    static int low_expire_entry(string key_prefix)    {    if (!key_prefix) return 0;    if (arrayp(cache[key_prefix])) {    // Leaf node. No need to loop.    really_low_expire_entry(key_prefix);    return 1;    }
Roxen.git/server/base_server/configuration.pike:362:    if (old) {    // FIXME: Warn?    low_expire_entry(key);    }       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 -  call_out(really_low_expire_entry, expire, key); +  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)    {    array(string|mapping(string:mixed))|string|    function(string, RequestID:string|int) res;    string key = url;
Roxen.git/server/base_server/configuration.pike:489:   /* A 'pri' is one of the ten priority objects. Each one holds a list    * of modules for that priority. They are all merged into one list for    * performance reasons later on.    */      array (Priority) allocate_pris()   {    return allocate(10, Priority)();   }    + // SNMP MIB for this configuration. + ADT.Trie mib = ADT.Trie(); + int mib_version;    -  + array(int) query_oid() + { +  return SNMP.RIS_OID_WEBSERVER + +  ({ 2, query("snmp_site_id"), }); + } +  + array(int) generate_module_oid(RoxenModule me) + { +  string s = otomod[me]; +  array(string) a = s/"#"; +  array(string) n = a[0]/4.0; +  return query_oid() + +  ({ 8, sizeof(n), @map(n, Gmp.bignum, 256), ((int)a[1]) + 1 }); + } +  + ADT.Trie generate_module_mib(array(int) oid, +  RoxenModule me, +  ModuleInfo moduleinfo, +  ModuleCopies module) + { +  return SNMP.SimpleMIB(oid, +  ({ +  UNDEFINED, +  SNMP.String(otomod[me]), +  SNMP.Integer(moduleinfo->type), +  })); + } +    // Cache some configuration variables.   private int sub_req_limit = 30;   private string internal_location = "/_internal/";      // The logging format used. This will probably move to the above   // mentioned module in the future.   private mapping (int|string:string) log_format = ([]);      // A list of priority objects   array (Priority) pri = allocate_pris();
Roxen.git/server/base_server/configuration.pike:3728:       if(module_type & MODULE_LAST)    pri[pr]->last_modules += ({ me });       if(module_type & MODULE_FILTER)    pri[pr]->filter_modules += ({ me });       if(module_type & MODULE_FIRST)    pri[pr]->first_modules += ({ me });    +  mib->merge(generate_module_mib(generate_module_oid(me) + ({ 1 }), +  me, moduleinfo, module)); +  if (me->query_snmp_mib) { +  mib->merge(me->query_snmp_mib(generate_module_oid(me) + ({ 2 }))); +  } +  mib_version++; +     invalidate_cache();   }      void call_high_start_callbacks (RoxenModule me, ModuleInfo moduleinfo,    void|int newly_added)   {    // This is icky, but I don't know if it's safe to remove. /mast    if(!me) return;    if(!moduleinfo) return;   
Roxen.git/server/base_server/configuration.pike:4943:   // report_debug("[defvar: %.1fms] ", (gethrtime()-st)/1000.0 );   // st = gethrtime();       mapping(string:mixed) retrieved_vars = retrieve("spider#0", this_object());    if (sizeof (retrieved_vars) && !retrieved_vars->compat_level)    // Upgrading an older configuration; default to 2.1 compatibility level.    set ("compat_level", "2.1");    setvars( retrieved_vars );      // report_debug("[restore: %.1fms] ", (gethrtime()-st)/1000.0 ); +  +  // FIXME: The default value ought to be stable. +  defvar("snmp_site_id", sizeof(roxen->configurations)+1, +  DLOCALE(0, "SNMP: Site id"), TYPE_INT, +  DLOCALE(0, "OID suffix to 1.3.6.1.4.1.8614.1.1.2 " +  "identifying this site.")); +  +  // FIXME: The following should move to a stage where +  // the config variables have been loaded. +  mib->merge(SNMP.SimpleMIB(query_oid(), +  ({ +  UNDEFINED, +  UNDEFINED, +  query_name, +  comment, +  lambda() { return SNMP.Counter64(sent); }, +  lambda() { return SNMP.Counter64(received); }, +  lambda() { return SNMP.Counter64(hsent); }, +  lambda() { return SNMP.Counter64(requests); }, +  UNDEFINED, // NOTE: Reserved for modules! +  }))); +  mib_version++;   }      static int arent_we_throttling_server () {    return !query("throttle");   }   static int arent_we_throttling_request() {    return !query("req_throttle");   }      #ifdef SNMP_AGENT   private static int(0..1) snmp_disabled() {    return (!snmp_global_disabled() && !query("snmp_process"));   }   private static int(0..1) snmp_global_disabled() {    return (!objectp(roxen->snmpagent));   }   #endif