Branch: Tag:

2002-11-05

2002-11-05 17:11:21 by Anders Johansson <anders@roxen.com>

Cache some config vars to avoid querying them every request.

Rev: server/base_server/configuration.pike:1.526

5:   // @appears Configuration   //! A site's main configuration    - constant cvs_version = "$Id: configuration.pike,v 1.525 2002/10/28 15:27:32 mast Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.526 2002/11/05 17:11:21 anders Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>
325:      string query_internal_location(RoxenModule|void mod)   { -  return query("InternalLoc")+(mod?replace(otomod[mod]||"", "#", "!")+"/":""); +  return internal_location+(mod?replace(otomod[mod]||"", "#", "!")+"/":"");   }      string query_name()
360:   }       + // 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) log_format = ([]);
1384:   #endif       // Locate internal location resources. -  if(!search(file, query("InternalLoc"))) +  if(has_prefix(file, internal_location))    {    TRACE_ENTER("Magic internal module location", 0);    RoxenModule module;    string name, rest;    function find_internal; -  if(2==sscanf(file[strlen(query("InternalLoc"))..], "%s/%s", name, rest) && +  if(2==sscanf(file[strlen(internal_location)..], "%s/%s", name, rest) &&    (module = find_module(replace(name, "!", "#"))) &&    (find_internal = module->find_internal))    {
1751:    int orig_internal_get = id->misc->internal_get;    id->misc->internal_get = internal_get;    RequestID root_id = id->root_id || id; -  int sub_req_limit = query("SubRequestLimit"); +     root_id->misc->_request_depth++;    if(sub_req_limit && root_id->misc->_request_depth > sub_req_limit) -  throw( ({ "Subrequest limit reached. (Possibly an insertion loop.)", backtrace() }) ); +  error("Subrequest limit reached. (Possibly an insertion loop.)");       mapping|int res;    mapping res2;
3501:    "all IP-numbers on your machine). If you specify a IP# in "    "the field it will take precedence over the hostname.")));    -  defvar("InternalLoc", "/_internal/", +  defvar("InternalLoc", internal_location,    DLOCALE(40, "Internal module resource mountpoint"),    TYPE_LOCATION|VAR_MORE|VAR_DEVELOPER,    DLOCALE(41, "Some modules may want to create links to internal "    "resources. This setting configures an internally handled "    "location that can be used for such purposes. Simply select "    "a location that you are not likely to use for regular " -  "resources.")); +  "resources.")) +  ->add_changed_callback(lambda(object v) { internal_location = v->query(); });    -  defvar("SubRequestLimit", 30, +  defvar("SubRequestLimit", sub_req_limit,    "Subrequest depth limit",    TYPE_INT | VAR_MORE,    "A limit for the number of nested sub requests for each request. " -  "This is intented to catch unintended infinite loops when for example " -  "inserting files in RXML. 0 for no limit." ); +  "This is intented to catch unintended infinite loops when for " +  "example inserting files in RXML. 0 for no limit." ) +  ->add_changed_callback(lambda(object v) { sub_req_limit = v->query(); });       // Throttling-related variables