httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r965408 - in /httpd/httpd/trunk: include/ap_mmn.h include/http_config.h modules/core/mod_so.c server/config.c
Date Mon, 19 Jul 2010 10:06:15 GMT
Author: sf
Date: Mon Jul 19 10:06:15 2010
New Revision: 965408

URL: http://svn.apache.org/viewvc?rev=965408&view=rev
Log:
Add ap_find_module_short_name() to quickly get the module short name
(i.e. symbol name with trailing "_module" removed) from the module_index.
To be used for logging.

Modified:
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/http_config.h
    httpd/httpd/trunk/modules/core/mod_so.c
    httpd/httpd/trunk/server/config.c

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=965408&r1=965407&r2=965408&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Mon Jul 19 10:06:15 2010
@@ -238,12 +238,14 @@
  * 20100714.0 (2.3.7-dev)  add access_checker_ex hook, add AUTHZ_DENIED_NO_USER
  *                         to authz_status, call authz providers twice to allow
  *                         authz without authenticated user
+ * 20100719.0 (2.3.7-dev)  Add symbol name parameter to ap_add_module and
+ *                         ap_add_loaded_module. Add ap_find_module_short_name
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20100714
+#define MODULE_MAGIC_NUMBER_MAJOR 20100719
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 

Modified: httpd/httpd/trunk/include/http_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_config.h?rev=965408&r1=965407&r2=965408&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_config.h (original)
+++ httpd/httpd/trunk/include/http_config.h Mon Jul 19 10:06:15 2010
@@ -671,8 +671,10 @@ AP_DECLARE(char *) ap_server_root_relati
  * Add a module to the server
  * @param m The module structure of the module to add
  * @param p The pool of the same lifetime as the module
+ * @param s The module's symbol name (used for logging)
  */
-AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p);
+AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
+                                       const char *s);
 
 /**
  * Remove a module from the server.  There are some caveats:
@@ -687,8 +689,10 @@ AP_DECLARE(void) ap_remove_module(module
  * Add a module to the chained modules list and the list of loaded modules
  * @param mod The module structure of the module to add
  * @param p The pool with the same lifetime as the module
+ * @param s The module's symbol name (used for logging)
  */
-AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p);
+AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
+                                              const char *s);
 /**
  * Remove a module fromthe chained modules list and the list of loaded modules
  * @param mod the module structure of the module to remove
@@ -701,6 +705,12 @@ AP_DECLARE(void) ap_remove_loaded_module
  */
 AP_DECLARE(const char *) ap_find_module_name(module *m);
 /**
+ * Find the short name of the module identified by the specified module index
+ * @param module_index The module index to get the name for
+ * @return the name of the module
+ */
+AP_DECLARE(const char *) ap_find_module_short_name(int module_index);
+/**
  * Find a module based on the name of the module
  * @param name the name of the module
  * @return the module structure if found, NULL otherwise

Modified: httpd/httpd/trunk/modules/core/mod_so.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/core/mod_so.c?rev=965408&r1=965407&r2=965408&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/core/mod_so.c (original)
+++ httpd/httpd/trunk/modules/core/mod_so.c Mon Jul 19 10:06:15 2010
@@ -278,7 +278,7 @@ static const char *load_module(cmd_parms
     /*
      * Add this module to the Apache core structures
      */
-    error = ap_add_loaded_module(modp, cmd->pool);
+    error = ap_add_loaded_module(modp, cmd->pool, modname);
     if (error) {
         return error;
     }

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=965408&r1=965407&r2=965408&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Mon Jul 19 10:06:15 2010
@@ -202,6 +202,9 @@ AP_DECLARE_DATA module **ap_loaded_modul
 
 static apr_hash_t *ap_config_hash = NULL;
 
+/* a list of the module symbol names with the trailing "_module"removed */
+static char **ap_module_short_names = NULL;
+
 typedef int (*handler_func)(request_rec *);
 typedef void *(*dir_maker_func)(apr_pool_t *, char *);
 typedef void *(*merger_func)(apr_pool_t *, void *, void *);
@@ -520,8 +523,11 @@ static void ap_add_module_commands(modul
 
 /* One-time setup for precompiled modules --- NOT to be done on restart */
 
-AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p)
+AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
+                                       const char *sym_name)
 {
+    ap_module_symbol_t *sym = ap_prelinked_module_symbols;
+
     /* This could be called from a LoadModule httpd.conf command,
      * after the file has been linked and the module structure within it
      * teased out...
@@ -549,8 +555,30 @@ AP_DECLARE(const char *) ap_add_module(m
                                 "reached. Please increase "
                                 "DYNAMIC_MODULE_LIMIT and recompile.", m->name);
         }
+
+    }
+    else if (!sym_name) {
+        while (sym->modp != NULL) {
+            if (sym->modp == m) {
+                sym_name = sym->name;
+                break;
+            }
+            sym++;
+        }
     }
 
+    if (sym_name) {
+        int len = strlen(sym_name);
+        int slen = strlen("_module");
+        if (len > slen && !strcmp(sym_name + len - slen, "_module")) {
+            len -= slen;
+        }
+
+        ap_module_short_names[m->module_index] = strdup(sym_name);
+        ap_module_short_names[m->module_index][len] = '\0';
+    }
+
+
     /* Some C compilers put a complete path into __FILE__, but we want
      * only the filename (e.g. mod_includes.c). So check for path
      * components (Unix and DOS), and remove them.
@@ -623,13 +651,17 @@ AP_DECLARE(void) ap_remove_module(module
         modp->next = modp->next->next;
     }
 
+    free(ap_module_short_names[m->module_index]);
+    ap_module_short_names[m->module_index] = NULL;
+
     m->module_index = -1; /* simulate being unloaded, should
                            * be unnecessary */
     dynamic_modules--;
     total_modules--;
 }
 
-AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p)
+AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
+                                              const char *short_name)
 {
     module **m;
     const char *error;
@@ -637,7 +669,7 @@ AP_DECLARE(const char *) ap_add_loaded_m
     /*
      *  Add module pointer to top of chained module list
      */
-    error = ap_add_module(mod, p);
+    error = ap_add_module(mod, p, short_name);
     if (error) {
         return error;
     }
@@ -709,12 +741,14 @@ AP_DECLARE(const char *) ap_setup_prelin
     conf_vector_length = max_modules;
 
     /*
-     *  Initialise list of loaded modules
+     *  Initialise list of loaded modules and short names
      */
     ap_loaded_modules = (module **)apr_palloc(process->pool,
         sizeof(module *) * conf_vector_length);
+    if (!ap_module_short_names)
+        ap_module_short_names = malloc(sizeof(char *) * conf_vector_length);
 
-    if (ap_loaded_modules == NULL) {
+    if (ap_loaded_modules == NULL || ap_module_short_names == NULL) {
         return "Ouch! Out of memory in ap_setup_prelinked_modules()!";
     }
 
@@ -727,7 +761,7 @@ AP_DECLARE(const char *) ap_setup_prelin
      *   Initialize chain of linked (=activate) modules
      */
     for (m = ap_prelinked_modules; *m != NULL; m++) {
-        error = ap_add_module(*m, process->pconf);
+        error = ap_add_module(*m, process->pconf, NULL);
         if (error) {
             return error;
         }
@@ -743,6 +777,13 @@ AP_DECLARE(const char *) ap_find_module_
     return m->name;
 }
 
+AP_DECLARE(const char *) ap_find_module_short_name(int module_index)
+{
+        if (module_index < 0)
+                return "-";
+        return ap_module_short_names[module_index];
+}
+
 AP_DECLARE(module *) ap_find_linked_module(const char *name)
 {
     module *modp;



Mime
View raw message