From e28ab8f48c891c03cf4b3a8ed88b98d38a561960 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Dec 2015 13:45:08 +0200 Subject: Separate brep module configuration from Apache server configuration --- web/apache/service | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'web/apache/service') diff --git a/web/apache/service b/web/apache/service index 33d5a0a..7eef81a 100644 --- a/web/apache/service +++ b/web/apache/service @@ -8,9 +8,7 @@ #include #include -#include #include -#include // move() #include #include @@ -23,14 +21,10 @@ namespace web class service: ::module { public: - using option_names = std::vector; - // Note that the module exemplar is stored by-reference. // template - service (const std::string& name, - M& exemplar, - option_names opts = option_names ()) + service (const std::string& name, M& exemplar) : ::module { STANDARD20_MODULE_STUFF, @@ -42,8 +36,7 @@ namespace web ®ister_hooks }, name_ (name), - exemplar_ (exemplar), - option_names_ (std::move (opts)) + exemplar_ (exemplar) { init_directives (); @@ -74,17 +67,31 @@ namespace web static void register_hooks (apr_pool_t*) noexcept { - // The registered function is called right after apache worker - // process is started. Called for every new process spawned. + // The config_finalizer() function is called at the end of Apache + // server configuration parsing. + // + ap_hook_post_config (&config_finalizer, NULL, NULL, APR_HOOK_LAST); + + // The worker_initializer() function is called right after Apache + // worker process is started. Called for every new process spawned. // ap_hook_child_init (&worker_initializer, NULL, NULL, APR_HOOK_LAST); - // The registered function is called for each client request. + // The request_handler () function is called for each client request. // ap_hook_handler (&request_handler, NULL, NULL, APR_HOOK_LAST); } template + static int + config_finalizer (apr_pool_t*, apr_pool_t*, apr_pool_t*, server_rec*) + noexcept + { + instance ()->options_parsed_ = true; + return OK; + } + + template static void worker_initializer (apr_pool_t*, server_rec* server) noexcept { @@ -112,7 +119,10 @@ namespace web init_worker (log& l) noexcept; static const char* - add_option (cmd_parms* parms, void* mconfig, const char* args) noexcept; + parse_option (cmd_parms* parms, void* mconfig, const char* args) noexcept; + + const char* + add_option (const char* name, optional value); template int handle (request& r, log& l) noexcept; @@ -120,8 +130,9 @@ namespace web private: std::string name_; module& exemplar_; - option_names option_names_; + option_descriptions option_descriptions_; name_values options_; + bool options_parsed_ = false; }; } } -- cgit v1.1