httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@organic.com>
Subject Re: AddModule doesn't work correctly (fwd)
Date Fri, 12 Sep 1997 22:18:21 GMT
On Fri, 12 Sep 1997, Dean Gaudet wrote:

> I think I'd like to see DYNAMIC_MODULE_LIMIT default to 0 if it's
> otherwise undefiend, and mod_dld, mod_dll or whatever they're called have
> Configure time rules added to them to bump DYNAMIC_MODULE_LIMIT to
> whatever is needed.
> 
> Or I'll just add -DDYNAMIC_MODULE_LIMIT=0 to my performance page :)

Is the extra 256 bytes per config really that performance-impeding? It's
only done at startup - merge_per_dir_configs() uses its own allocation
of total_modules, for example.

Anyhow, here's a patch that:

1. Fixes create_empty_config (the previous patch)
2. Add code to add_module() to exit and complain if you exceed your
   DYNAMIC_MODULE_LIMIT
3. Adds #ifndefs around #define DYNAMIC_MODULE_LIMIT so you can change it
   at compile-time without editing httpd.h

Index: main/http_config.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/http_config.c,v
retrieving revision 1.78
diff -u -r1.78 http_config.c
--- http_config.c	1997/08/31 21:28:49	1.78
+++ http_config.c	1997/09/12 22:16:30
@@ -83,8 +83,15 @@
  * of modules which control just about all of the server operation.
  */
 
-/* total_modules is the number of modules linked in.  */
+/* total_modules is the number of modules that have been linked
+ * into the server.
+ */
 static int total_modules = 0;
+/* dynamic_modules is the number of modules that have been added
+ * after the pre-linked ones have been set up. It shouldn't be larger
+ * than DYNAMIC_MODULE_LIMIT.
+ */
+static int dynamic_modules = 0;
 module *top_module = NULL;
     
 typedef int (*handler_func)(request_rec *);
@@ -117,7 +124,8 @@
 void *
 create_empty_config (pool *p)
 {
-   void **conf_vector = (void **)pcalloc(p, sizeof(void*) * total_modules);
+   void **conf_vector = (void **)pcalloc(p, sizeof(void*) *
+					 (total_modules+DYNAMIC_MODULE_LIMIT));
    return (void *)conf_vector;
 }
 
@@ -472,8 +480,17 @@
     }
     if (m->module_index == -1) {
 	m->module_index = total_modules++;
+	dynamic_modules++;
+
+	if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
+	    fprintf(stderr, "httpd: module \"%s\" could not be loaded, because"
+		    " the dynamic\n", m->name);
+	    fprintf(stderr, "module limit was reached. Please increase "
+		    "DYNAMIC_MODULE_LIMIT and recompile.\n");
+	    exit(1);
+	}
     }
-    
+
     /* 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.
Index: main/httpd.h
===================================================================
RCS file: /export/home/cvs/apachen/src/main/httpd.h,v
retrieving revision 1.147
diff -u -r1.147 httpd.h
--- httpd.h	1997/09/07 15:39:48	1.147
+++ httpd.h	1997/09/12 22:16:34
@@ -88,7 +88,9 @@
 #endif /* DOCUMENT_LOCATION */
 
 /* Max. number of dynamically loaded modules */
+#ifndef DYNAMIC_MODULE_LIMIT
 #define DYNAMIC_MODULE_LIMIT 64
+#endif /* DYNAMIC_MODULE_LIMIT */
 
 /* Default administrator's address */
 #define DEFAULT_ADMIN "[no address given]"


-- Alexei Kosut <akosut@organic.com>



Mime
View raw message