httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@organic.com>
Subject Fix for screwed-up add_module
Date Mon, 07 Jul 1997 19:46:41 GMT
I just discovered that, since last November, Apache's facilities for
dealing with dynamic loading of modules don't work. Tom Tromey's patch
that introduced the AddModule directive screwed up add_module() in a way
that made it so that if anyone actually used mod_dld or a similar module
to load a module at runtime, it would do bad things (core dump, most
likely). The fact that we received no bug reports on this probably just
means no one uses mod_dld. Understandable, since we don't really support
it. However, I've been working on NT support for modules as DLLs (I've
almost got it working, too), and I came across this.

The problem is that the AddModule patch created two variables to keep
track of how many modules were loaded into the server, total_modules for
the number of "loaded" modules, and num_modules for the number of "linked"
modules. Only thing is, the code didn't update the right numbers when
add_module() was called on a non-preloaded module, so it would assign that
module a module index that was already in use.

The following patch combines the two variables back into one, and makes it
work correctly. This could technically go into 1.2.x, since it is a fix
for a bug that occurs in 1.2, but I'd say not to bother, since dynamic
loading isn't a "supported" feature. For 1.3, then. (I've used a unified
diff, just to try it out. I'm not sure if I like it yet):

Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.55
diff -u -r1.55 http_config.c
--- http_config.c	1997/06/30 21:18:11	1.55
+++ http_config.c	1997/07/07 19:37:17
@@ -83,8 +83,6 @@
  * of modules which control just about all of the server operation.
  */
 
-/* num_modules is the number of currently active modules.  */
-static int num_modules = 0;    
 /* total_modules is the number of modules linked in.  */
 static int total_modules = 0;
 module *top_module = NULL;
@@ -470,7 +468,7 @@
 	top_module = m;
     }
     if (m->module_index == -1) {
-	m->module_index = num_modules++;
+	m->module_index = total_modules++;
     }
     /** XXX: this will be slow if there's lots of add_modules */
     build_method_shortcuts ();
@@ -539,8 +537,6 @@
 	*m = NULL;
 	m = next_m;
     }
-
-    num_modules = 0;
 
     /* This is required; so we add it always.  */
     add_named_module ("http_core.c");


-- Alexei Kosut <akosut@organic.com>


Mime
View raw message