From 45aec70e4b577aaec17720b6082fe6b8ad0e243f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Mar 2016 15:59:02 +0300 Subject: Get rid of using the 'root exemplar' for request handling --- web/apache/service.txx | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'web/apache/service.txx') diff --git a/web/apache/service.txx b/web/apache/service.txx index 1d0693a..2e8a3e5 100644 --- a/web/apache/service.txx +++ b/web/apache/service.txx @@ -25,24 +25,21 @@ namespace web const M* exemplar (dynamic_cast (&exemplar_)); assert (exemplar != nullptr); - // For each directory configuration context create the module exemplar - // as a deep copy of the exemplar_ member and initialize it with the - // context-specific option list. Note that there can be contexts - // having no module options specified for them and no options - // inherited from enclosing contexts. Such contexts will not appear in - // the options_ map. Meanwhile 'SetHandler ' directive can be - // in effect for such contexts, and we should be ready to handle - // requests for them (by using the "root exemplar"). + // For each directory configuration context, for which the module + // allowed to handle a request, create the module exemplar as a deep + // copy of the exemplar_ member, and initialize it with the + // context-specific option list. // for (const auto& o: options_) { const context* c (o.first); - if (c->server != nullptr) // Is a directory configuration context. + if (c->server != nullptr && // Is a directory configuration context. + c->handling == request_handling::allowed) { auto r ( exemplars_.emplace ( - make_context_id (c), + c, std::unique_ptr (new M (*exemplar)))); r.first->second->init (o.second, l); @@ -52,13 +49,6 @@ namespace web // Options are not needed anymore. Free up the space. // options_.clear (); - - // Initialize the "root exemplar" by default (with no options). It - // will be used to handle requests for configuration contexts having - // no options specified, and no options inherited from enclosing - // contexts. - // - exemplar_.init (name_values (), l); } catch (const std::exception& e) { @@ -105,37 +95,31 @@ namespace web assert (r->per_dir_config != nullptr); - // Obtain the request-associated configuration context id. + // Obtain the request-associated configuration context. // - context_id id ( - make_context_id (ap_get_module_config (r->per_dir_config, srv))); + const context* cx ( + context_cast (ap_get_module_config (r->per_dir_config, srv))); - assert (!is_null (id)); + assert (cx != nullptr); request rq (r); log lg (r->server, srv); - return srv->template handle (rq, id, lg); + return srv->template handle (rq, cx, lg); } template int service:: - handle (request& rq, context_id id, log& lg) const + handle (request& rq, const context* cx, log& lg) const { static const std::string func_name ( "web::apache::service<" + name_ + ">::handle"); try { - auto i (exemplars_.find (id)); - - // Use the context-specific exemplar if found, otherwise use the - // default one. - // - const module* exemplar (i != exemplars_.end () - ? i->second.get () - : &exemplar_); + auto i (exemplars_.find (cx)); + assert (i != exemplars_.end ()); - const M* e (dynamic_cast (exemplar)); + const M* e (dynamic_cast (i->second.get ())); assert (e != nullptr); for (M m (*e);;) -- cgit v1.1