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.632 2008/02/28 19:37:44 jonasw Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.633 2008/03/19 14:06:47 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:480:   /* 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)();   }    + array(int) query_oid() + { +  return SNMP.RIS_OID_WEBSERVER + ({ 2 }); + }    -  + array(int) generate_module_oid_segment(RoxenModule me) + { +  string s = otomod[me]; +  array(string) a = s/"#"; +  return ({ sizeof(a[0]), @((array(int))a[0]), ((int)a[1]) + 1 }); + } +  + ADT.Trie generate_module_mib(array(int) oid, +  array(int) oid_suffix, +  RoxenModule me, +  ModuleInfo moduleinfo, +  ModuleCopies module) + { +  array(int) segment = generate_module_oid_segment(me); +  return SNMP.SimpleMIB(oid, +  oid_suffix + segment, +  ({ +  UNDEFINED, +  SNMP.Integer(segment[-1], "moduleCopy"), +  SNMP.String(otomod[me], +  "moduleIdentifier"), +  SNMP.Integer(moduleinfo->type, +  "moduleType"), +  SNMP.String(me->cvs_version || "", +  "moduleVersion"), +  })); + } +    // 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();      mapping modules = ([]);   //! All enabled modules in this site.   //! The format is "module":{ "copies":([ num:instance, ... ]) }      mapping (RoxenModule:string) otomod = ([]);   //! A mapping from the module objects to module names    -  + mapping(string:int) counters = ([]);      // Caches to speed up the handling of the module search.   // They are all sorted in priority order, and created by the functions   // below.   private array (function) url_module_cache, last_module_cache;   private array (function) logger_module_cache, first_module_cache;   private array (function) filter_module_cache;   private array (array (string|function)) location_module_cache;   private mapping (string:array (function)) file_extension_module_cache=([]);   private mapping (string:array (RoxenModule)) provider_module_cache=([]);
Roxen.git/server/base_server/configuration.pike:3203:    1024, 65536 );    // and new connections does not even have to care.    throttler = 0;    }      #ifdef SNMP_AGENT    if(query("snmp_process") && objectp(roxen->snmpagent))    roxen->snmpagent->add_virtserv(get_config_id());   #endif    +  foreach(registered_urls, string url) { +  mapping(string:string|Configuration|Protocol) port_info = roxen.urls[url]; +  +  foreach((port_info && port_info->ports) || ({}), Protocol prot) { +  if ((prot->prot_name != "snmp") || (!prot->mib)) { +  continue;    }    -  +  string path = port_info->path || ""; +  if (has_prefix(path, "/")) { +  path = path[1..]; +  } +  if (has_suffix(path, "/")) { +  path = path[..sizeof(path)-2]; +  } +  +  array(int) oid_suffix = ({ sizeof(path), @((array(int))path) }); +  +  ADT.Trie mib = +  SNMP.SimpleMIB(query_oid(), oid_suffix, +  ({ +  UNDEFINED, +  UNDEFINED, +  query_name, +  comment, +  SNMP.Counter64(lambda() { return sent; }), +  SNMP.Counter64(lambda() { return received; }), +  SNMP.Counter64(lambda() { return hsent; }), +  SNMP.Counter64(lambda() { return requests; }), +  UNDEFINED, // NOTE: Reserved for modules! +  })); +  SNMP.set_owner(mib, this_object()); +  prot->mib->merge(mib); +  } +  } + } +    void save_me()   {    save_one( 0 );   }      void save(int|void all)   //! Save this configuration. If all is included, save all configuration   //! global variables as well, otherwise only all module variables.   {    if(all)
Roxen.git/server/base_server/configuration.pike:3561:    }   #endif    } else {    me->defvar("_priority", 0, "", TYPE_INT, "", 0, 1);    }       mapping(string:mixed) stored_vars = retrieve(modname + "#" + id, this_object());    int has_stored_vars = sizeof (stored_vars); // A little ugly, but it suffices.    me->setvars(stored_vars);    +  if (!module[id]) +  counters[moduleinfo->counter]++; +     module[ id ] = me;    otomod[ me ] = modname+"#"+id;       if(!nostart) call_start_callbacks( me, moduleinfo, module );      #ifdef MODULE_DEBUG    if (enable_module_batch_msgs) {    if(moduleinfo->config_locked[this_object()])    report_debug("\bLocked %6.1fms\n", (gethrtime()-start_time)/1000.0);    else
Roxen.git/server/base_server/configuration.pike:3709:       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 });    +  foreach(registered_urls, string url) { +  mapping(string:string|Configuration|Protocol) port_info = roxen.urls[url]; +  +  foreach((port_info && port_info->ports) || ({}), Protocol prot) { +  if ((prot->prot_name != "snmp") || (!prot->mib)) { +  continue; +  } +  +  string path = port_info->path || ""; +  if (has_prefix(path, "/")) { +  path = path[1..]; +  } +  if (has_suffix(path, "/")) { +  path = path[..sizeof(path)-2]; +  } +  +  array(int) oid_suffix = ({ sizeof(path), @((array(int))path) }); +  +  ADT.Trie sub_mib = generate_module_mib(query_oid() + ({ 8, 1 }), +  oid_suffix, me, moduleinfo, module); +  SNMP.set_owner(sub_mib, this_object(), me); +  +  prot->mib->merge(sub_mib); +  +  if (me->query_snmp_mib) { +  array(int) segment = generate_module_oid_segment(me); +  sub_mib = me->query_snmp_mib(query_oid() + ({ 8, 2 }) + +  segment[..sizeof(segment)-2], +  oid_suffix + ({ segment[-1] })); +  SNMP.set_owner(sub_mib, this_object(), me); +  prot->mib->merge(sub_mib); +  } +  } +  } +     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:3840:    pri[pr]->filter_modules -= ({ me });       if( moduleinfo->type & MODULE_FIRST ) {    for(pr=0; pr<10; pr++)    pri[pr]->first_modules -= ({ me });    }       if( moduleinfo->type & MODULE_LOGGER )    for(pr=0; pr<10; pr++)    pri[pr]->logger_modules -= ({ me }); +  +  foreach(registered_urls, string url) { +  mapping(string:string|Configuration|Protocol) port_info = roxen.urls[url]; +  foreach((port_info && port_info->ports) || ({}), Protocol prot) { +  if ((prot->prot_name != "snmp") || (!prot->mib)) { +  continue;    }    -  +  SNMP.remove_owned(prot->mib, this_object(), me); +  } +  } + } +    int disable_module( string modname, int|void nodest )   {    MODULE_LOCK (2);    RoxenModule me;    int id, pr;    sscanf(modname, "%s#%d", modname, id );       if( datacache ) datacache->flush();       ModuleInfo moduleinfo = roxen.find_module( modname );
Roxen.git/server/base_server/configuration.pike:3869:    "No module by that name: \"%s\".\n"), modname);    return 0;    }       me = module[id];    m_delete(module->copies, id);       if(!sizeof(module->copies))    m_delete( modules, modname );    +  if (moduleinfo->counter) { +  counters[moduleinfo->counter]--; +  } +     invalidate_cache();       if(!me)    {    report_error("disable_module(): " +    LOC_M(43, "Failed to disable module \"%s\".\n"),    descr);    return 0;    }