Commit 9f5e240d authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

Introduce ap_(get|set)_core_module_config() functions/macros and use them

everywhere.

We know that the core module has module_index 0. Therefore we can save
some pointer operations in ap_get_module_config(cv, &core_module) and
ap_set_module_config(cv, &core_module, val). As these are called rather often,
this may actually have some (small) measurable effect.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1132781 13f79535-47bb-0310-9956-ffa450edef68
parent 407c2ecb
Loading
Loading
Loading
Loading
+1 −0
Changes for build/build-modules-c.awk: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
# limitations under the License.
BEGIN {
    RS = " "
    # the core module must come first
    modules[n++] = "core"
    pmodules[pn++] = "core"
} 
+2 −1
Changes for include/ap_mmn.h: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -331,6 +331,7 @@
 *                         Add members of core_request_config: document_root,
 *                         context_document_root, context_prefix.
 *                         Add ap_context_*(), ap_set_context_info(), ap_set_document_root()
 * 20110605.1 (2.3.13-dev) add ap_(get|set)_core_module_config()
 */

#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -338,7 +339,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110605
#endif
#define MODULE_MAGIC_NUMBER_MINOR 0                    /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 1                    /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+28 −0
Changes for include/http_core.h: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -318,6 +318,34 @@ AP_DECLARE(int) ap_satisfies(request_rec *r);
 */
AP_DECLARE_DATA extern module core_module;

/**
 * Accessor for core_module's specific data. Equivalent to
 * ap_get_module_config(cv, &core_module) but more efficient.
 * @param cv The vector in which the modules configuration is stored.
 *        usually r->per_dir_config or s->module_config
 * @return The module-specific data
 */
AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv);

/**
 * Accessor to set core_module's specific data. Equivalent to
 * ap_set_module_config(cv, &core_module, val) but more efficient.
 * @param cv The vector in which the modules configuration is stored.
 *        usually r->per_dir_config or s->module_config
 * @param val The module-specific data to set
 */
AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val);

#ifndef AP_DEBUG
#define AP_CORE_MODULE_INDEX  0
#define ap_get_core_module_config(v) \
    (((void **)(v))[AP_CORE_MODULE_INDEX])
#define ap_set_core_module_config(v, val) \
    ((((void **)(v))[AP_CORE_MODULE_INDEX]) = (val))
#else
#define AP_CORE_MODULE_INDEX  (AP_DEBUG_ASSERT(core_module.module_index == 0), 0)
#endif

/**
 * @brief  Per-request configuration 
*/
+1 −2
Changes for modules/cache/mod_cache_disk.c: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -409,8 +409,7 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key)
    disk_cache_conf *conf = ap_get_module_config(r->server->module_config,
                                                 &cache_disk_module);
#ifdef APR_SENDFILE_ENABLED
    core_dir_config *coreconf = ap_get_module_config(r->per_dir_config,
                                                     &core_module);
    core_dir_config *coreconf = ap_get_core_module_config(r->per_dir_config);
#endif
    apr_finfo_t finfo;
    cache_object_t *obj;
+1 −1
Changes for modules/echo/mod_echo.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ static int process_echo_connection(conn_rec *c)
        }

        if (!csd) {
            csd = ap_get_module_config(c->conn_config, &core_module);
            csd = ap_get_core_module_config(c->conn_config);
            apr_socket_timeout_set(csd, c->base_server->keep_alive_timeout);
        }

Loading