You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Tom Tromey <tr...@creche.cygnus.com> on 1996/10/16 18:30:43 UTC

addmodule revisited

My previous AddModule patch had a serious bug.  I forget the precise
symptoms, but basically it had to do with various arrays (eg
conf_vector) not being sized properly.

I have a new version of the patch that fixes this.  This patch
slightly changes the meaning module_index; whereas module_index used
to be the location of the module in the module list, it is now just
the index at which the module is linked in.

I also changed the default module_index in STANDARD_MODULE_STUFF to be
-1 instead of 0.  This change is not really necessary, but I thought
it didn't really make sense for the default value to be a valid index.

Changing the module_index makes find_module_name constant time.

It is also now an error if AddModule can't find the named module.

BTW I noticed that mod_info is inherently broken if you are using
mod_dld (this is true with or without the AddModule patch).  If you
load a module using mod_dld there is no way to get its name.  Another
reason the module name should go in the module structure, I guess.

The patch is appended.  It is also available for ftp from
ftp.cygnus.com in pub/tromey.  I tested this patch by running the
modified Apache against my test suite.

Tom
-- 
tromey@cygnus.com                 Member, League for Programming Freedom

Index: Configuration.tmpl
===================================================================
RCS file: /export/home/cvs/apache/src/Configuration.tmpl,v
retrieving revision 1.44
diff -c -5 -r1.44 Configuration.tmpl
*** Configuration.tmpl	1996/10/09 17:36:18	1.44
--- Configuration.tmpl	1996/10/16 15:22:34
***************
*** 7,17 ****
  
  # The template should only be changed when a new system or module is added,
  # or an existing one modified. This will also most likely require some minor
  # changes to Configure to recognize those changes.
  
! # There are 4 types of lines here:
  
  # '#' comments, distinguished by having a '#' as the first non-blank character
  #
  # Makefile options, such as CC=gcc, etc...
  #
--- 7,17 ----
  
  # The template should only be changed when a new system or module is added,
  # or an existing one modified. This will also most likely require some minor
  # changes to Configure to recognize those changes.
  
! # There are 5 types of lines here:
  
  # '#' comments, distinguished by having a '#' as the first non-blank character
  #
  # Makefile options, such as CC=gcc, etc...
  #
***************
*** 19,28 ****
--- 19,33 ----
  # control Configure's behavior as far as how to create Makefile.
  #
  # Module selection lines, distinguished by having 'Module' at the front.
  # These list the configured modules, in priority order (highest priority
  # first).  They're down at the bottom.
+ #
+ # Optional module selection lines, distinguished by having `%Module'
+ # at the front.  These specify a module that is to be compiled in (but
+ # not enabled).  The AddModule directive can be used to enable such a
+ # module.  By default no such modules are defined.
  
  
  ################################################################
  # Makefile configuration
  #
Index: Configure
===================================================================
RCS file: /export/home/cvs/apache/src/Configure,v
retrieving revision 1.27
diff -c -5 -r1.27 Configure
*** Configure	1996/10/10 02:24:37	1.27
--- Configure	1996/10/16 15:22:42
***************
*** 33,44 ****
  sed 's/#.*//' $file | sed '/^[ 	]*$/d' | sed 's/[ 	]*$//' | \
   sed 's/^Rule[ 	]*/##Rule:/' > $tmpfile
  
  # Check for syntax errors...
  
! if egrep -v '^Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile | \
!    grep -v = > /dev/null
  then
     echo "Syntax error --- The configuration file is used only to"
     echo "define the list of included modules or to set Makefile"
     echo "options or Configure rules, and I don't see that at all:"
     egrep -v '^Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile | \
--- 33,44 ----
  sed 's/#.*//' $file | sed '/^[ 	]*$/d' | sed 's/[ 	]*$//' | \
   sed 's/^Rule[ 	]*/##Rule:/' > $tmpfile
  
  # Check for syntax errors...
  
! if egrep -v '^%?Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile \
!    | grep -v = > /dev/null
  then
     echo "Syntax error --- The configuration file is used only to"
     echo "define the list of included modules or to set Makefile"
     echo "options or Configure rules, and I don't see that at all:"
     egrep -v '^Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile | \
***************
*** 49,83 ****
  # File is OK --- make backup copies of things and then get the new ones:
  
  if [ -f Makefile ] ; then mv Makefile Makefile.bak; fi
  if [ -f modules.c ] ; then mv modules.c modules.c.bak; fi
  
! awk >modules.c <$tmpfile '\
!    BEGIN { modules[n++] = "core_module" } \
!    /^Module/ { modules[n++] = $2 } \
     END { print "/* modules.c --- automatically generated by Apache"; \
           print " * configuration script.  DO NOT HAND EDIT!!!!!"; \
           print " */"; \
           print ""; \
  	 print "#include \"httpd.h\""; \
  	 print "#include \"http_config.h\""; \
           print ""; \
!          for (i = 0; i < n; ++i) { \
!              printf ("extern module %s;\n", modules[i]); \
           } \
           print ""; \
           print "module *prelinked_modules[] = {"; \
           for (i = 0; i < n; ++i) { \
!              printf "  &%s,\n", modules[i]; \
           } \
  	 print "  NULL"; \
           print "};"; \
           print "char *module_names[] = {"; \
!          for (i = n-1; i > -1; --i) { \
               printf "  \"%s\",\n", modules[i]; \
           } \
!        print "  NULL"; \
           print "};"; \
     }'
  
  #
  # Add module set only
--- 49,96 ----
  # File is OK --- make backup copies of things and then get the new ones:
  
  if [ -f Makefile ] ; then mv Makefile Makefile.bak; fi
  if [ -f modules.c ] ; then mv modules.c modules.c.bak; fi
  
! sed -e 's/_module//' $tmpfile | awk >modules.c '\
!    BEGIN { modules[n++] = "core" ; pmodules[pn++] = "core"} \
!    /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } \
!    /^%Module/ { pmodules[pn++] = $2 } \
     END { print "/* modules.c --- automatically generated by Apache"; \
           print " * configuration script.  DO NOT HAND EDIT!!!!!"; \
           print " */"; \
           print ""; \
  	 print "#include \"httpd.h\""; \
  	 print "#include \"http_config.h\""; \
           print ""; \
!          for (i = 0; i < pn; ++i) { \
!              printf ("extern module %s_module;\n", pmodules[i]); \
           } \
           print ""; \
           print "module *prelinked_modules[] = {"; \
           for (i = 0; i < n; ++i) { \
!              printf "  &%s_module,\n", modules[i]; \
           } \
  	 print "  NULL"; \
           print "};"; \
           print "char *module_names[] = {"; \
!          for (i = 0; i < n; ++i) { \
               printf "  \"%s\",\n", modules[i]; \
           } \
!          print "  NULL"; \
!          print "};"; \
!          print "module *preloaded_modules[] = {"; \
!          for (i = 0; i < pn; ++i) { \
!              printf "  &%s_module,\n", pmodules[i]; \
!          } \
! 	 print "  NULL"; \
!          print "};"; \
!          print "char *preloaded_module_names[] = {"; \
!          for (i = 0; i < pn; ++i) { \
!              printf "  \"%s\",\n", pmodules[i]; \
!          } \
!          print "  NULL"; \
           print "};"; \
     }'
  
  #
  # Add module set only
***************
*** 87,96 ****
--- 100,110 ----
  	   print "# and configuration file by Apache config script. "; \
  	   print "# Hand-edited changes will be lost if the config script"; \
  	   print "# is re-run."; \
           } \
     /^Module/ { modules[n++] = $3 } \
+    /^%Module/ { modules[n++] = $3 } \
     END { print "MODULES=\\"; \
           for (i = 0; i < n; ++i) { \
               if (i < n-1) printf ("  %s \\\n", modules[i]); \
               else printf ("  %s\n", modules[i]); \
           } \
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.26
diff -c -5 -r1.26 http_config.c
*** http_config.c	1996/10/09 15:23:08	1.26
--- http_config.c	1996/10/16 15:23:02
***************
*** 83,93 ****
--- 83,96 ----
   *
   * We begin with the functions which deal with the linked list
   * 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;
      
  typedef int (*handler)(request_rec *);
  typedef void *(*maker)(pool *);
  typedef void *(*dir_maker)(pool *, char *);
***************
*** 119,136 ****
  }
  
  void *
  create_empty_config (pool *p)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * num_modules);
     return (void *)conf_vector;
  }
  
  void *
  create_default_per_dir_config (pool *p)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (num_modules+DYNAMIC_MODULE_LIMIT));
     module *modp;
  
     for (modp = top_module; modp; modp = modp->next) {
         dir_maker df = modp->create_dir_config;
  
--- 122,139 ----
  }
  
  void *
  create_empty_config (pool *p)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * total_modules);
     return (void *)conf_vector;
  }
  
  void *
  create_default_per_dir_config (pool *p)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (total_modules+DYNAMIC_MODULE_LIMIT));
     module *modp;
  
     for (modp = top_module; modp; modp = modp->next) {
         dir_maker df = modp->create_dir_config;
  
***************
*** 141,151 ****
  }
  
  void *
  merge_per_dir_configs (pool *p, void *base, void *new)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * num_modules);
     void **base_vector = (void **) base;
     void **new_vector = (void **) new;
     module *modp;
  
     for (modp = top_module; modp; modp = modp->next) {
--- 144,154 ----
  }
  
  void *
  merge_per_dir_configs (pool *p, void *base, void *new)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * total_modules);
     void **base_vector = (void **) base;
     void **new_vector = (void **) new;
     module *modp;
  
     for (modp = top_module; modp; modp = modp->next) {
***************
*** 162,172 ****
  }
  
  void *
  create_server_config (pool *p, server_rec *s)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (num_modules+DYNAMIC_MODULE_LIMIT));
     module *modp;
  
     for (modp = top_module; modp; modp = modp->next) {
         if (modp->create_server_config)
  	   conf_vector[modp->module_index]=(*modp->create_server_config)(p,s);
--- 165,175 ----
  }
  
  void *
  create_server_config (pool *p, server_rec *s)
  {
!    void **conf_vector = (void **)pcalloc(p, sizeof(void*) * (total_modules+DYNAMIC_MODULE_LIMIT));
     module *modp;
  
     for (modp = top_module; modp; modp = modp->next) {
         if (modp->create_server_config)
  	   conf_vector[modp->module_index]=(*modp->create_server_config)(p,s);
***************
*** 371,394 ****
  		        "version of Apache.\n", m->name);
  	fprintf(stderr, "Please contact the author for the correct version.\n");
  	exit(1);
      }
  
!     m->next = top_module;
!     top_module = m;
!     m->module_index = num_modules++;
  }
  
  void setup_prelinked_modules ()
  {
!     extern module *prelinked_modules[];
!     module **m = prelinked_modules;
  
!     while (*m) {
          add_module (*m);
- 	++m;
      }
  }
  
  /*****************************************************************
   *
   * Resource, access, and .htaccess config files now parsed by a common
--- 374,455 ----
  		        "version of Apache.\n", m->name);
  	fprintf(stderr, "Please contact the author for the correct version.\n");
  	exit(1);
      }
  
!     if (m->next == NULL) {
!         m->next = top_module;
! 	top_module = m;
!     }
!     if (m->module_index == -1) {
! 	m->module_index = num_modules++;
!     }
  }
  
  void setup_prelinked_modules ()
  {
!     extern module *prelinked_modules[], *preloaded_modules[];
!     module **m;
  
!     /* First, set all module indices, and init total_modules.  */
!     total_modules = 0;
!     for (m = preloaded_modules; *m; ++m, ++total_modules) {
!         (*m)->module_index = total_modules;
!     }
! 
!     for (m = prelinked_modules; *m; ++m) {
          add_module (*m);
      }
+ }
+ 
+ char *find_module_name (module *m)
+ {
+     extern char *preloaded_module_names[];
+     int i;
+ 
+     if (m->module_index >= 0 && m->module_index < total_modules)
+       return preloaded_module_names[m->module_index];
+     return NULL;
+ }
+ 
+ /* Add a named module.  Returns 1 if module found, 0 otherwise.  */
+ int add_named_module (char *name)
+ {
+     extern module *preloaded_modules[];
+     extern char *preloaded_module_names[];
+     int i;
+ 
+     for (i = 0; preloaded_module_names[i]; ++i) {
+         if (strcmp (preloaded_module_names[i], name) == 0) {
+ 	    /* Only add modules that are not already enabled.  */
+ 	    if (preloaded_modules[i]->next == NULL) {
+ 	        add_module (preloaded_modules[i]);
+ 	    }
+ 	    return 1;
+ 	}
+     }
+ 
+     return 0;
+ }
+ 
+ /* Clear the internal list of modules, in preparation for starting
+    over.  */
+ void clear_module_list ()
+ {
+     module **m = &top_module;
+     module **next_m;
+ 
+     while (*m) {
+ 	next_m = &((*m)->next);
+ 	*m = NULL;
+ 	m = next_m;
+     }
+ 
+     num_modules = 0;
+ 
+     /* This is required; so we add it always.  */
+     add_named_module ("core");
  }
  
  /*****************************************************************
   *
   * Resource, access, and .htaccess config files now parsed by a common
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.15
diff -c -5 -r1.15 http_config.h
*** http_config.h	1996/10/09 15:23:08	1.15
--- http_config.h	1996/10/16 15:23:14
***************
*** 226,236 ****
   * the API (the server can detect an old-format module, and either
   * handle it back-compatibly, or at least signal an error).
   */
  
  #define MODULE_MAGIC_NUMBER 19961007
! #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, 0, __FILE__, NULL
  
  /* Generic accessors for other modules to get at their own module-specific
   * data
   */
  
--- 226,236 ----
   * the API (the server can detect an old-format module, and either
   * handle it back-compatibly, or at least signal an error).
   */
  
  #define MODULE_MAGIC_NUMBER 19961007
! #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, -1, __FILE__, NULL
  
  /* Generic accessors for other modules to get at their own module-specific
   * data
   */
  
***************
*** 249,258 ****
--- 249,261 ----
  char *server_root_relative (pool *p, char *fname);
       
  /* Finally, the hook for dynamically loading modules in... */
  
  void add_module (module *m);
+ int add_named_module (char *name);
+ void clear_module_list ();
+ char *find_module_name (module *m);
  
  #ifdef CORE_PRIVATE
  
  /* For http_main.c... */
  
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.36
diff -c -5 -r1.36 http_core.c
*** http_core.c	1996/10/14 00:18:46	1.36
--- http_core.c	1996/10/16 15:23:34
***************
*** 746,755 ****
--- 746,768 ----
      
      if (errmsg == end_virthost_magic) return NULL;
      return errmsg;
  }
  
+ char *add_module_command (cmd_parms *cmd, void *dummy, char *arg)
+ {
+   if (add_named_module (arg))
+     return NULL;
+   return "required module not found";
+ }
+ 
+ char *clear_module_list_command (cmd_parms *cmd, void *dummy)
+ {
+   clear_module_list ();
+   return NULL;
+ }
+ 
  char *set_server_string_slot (cmd_parms *cmd, void *dummy, char *arg)
  {
      /* This one's pretty generic... */
    
      int offset = (int)cmd->info;
***************
*** 1120,1129 ****
--- 1133,1145 ----
    "'*', a numeric IP address, or the name of a host with a unique IP address"},
  { "Listen", set_listener, NULL, RSRC_CONF, TAKE1,
        "a port number or a numeric IP address and a port number"},
  { "<VirtualHost", virtualhost_section, NULL, RSRC_CONF, RAW_ARGS, NULL },
  { "</VirtualHost>", end_virtualhost_section, NULL, RSRC_CONF, NO_ARGS, NULL },
+ { "AddModule", add_module_command, NULL, RSRC_CONF, ITERATE,
+   "the name of a module" },
+ { "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS, NULL },
  { NULL },
  };
  
  /*****************************************************************
   *
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.76
diff -c -5 -r1.76 http_main.c
*** http_main.c	1996/10/06 02:25:03	1.76
--- http_main.c	1996/10/16 15:28:45
***************
*** 341,355 ****
  }
  #endif
  
  void usage(char *bin)
  {
!     fprintf(stderr,"Usage: %s [-d directory] [-f file] [-v] [-h]\n",bin);
      fprintf(stderr,"-d directory : specify an alternate initial ServerRoot\n");
      fprintf(stderr,"-f file : specify an alternate ServerConfigFile\n");
      fprintf(stderr,"-v : show version number\n");
      fprintf(stderr,"-h : list directives\n");
      exit(1);
  }
  
  /*****************************************************************
   *
--- 341,356 ----
  }
  #endif
  
  void usage(char *bin)
  {
!     fprintf(stderr,"Usage: %s [-d directory] [-f file] [-v] [-h] [-l]\n",bin);
      fprintf(stderr,"-d directory : specify an alternate initial ServerRoot\n");
      fprintf(stderr,"-f file : specify an alternate ServerConfigFile\n");
      fprintf(stderr,"-v : show version number\n");
      fprintf(stderr,"-h : list directives\n");
+     fprintf(stderr,"-l : list modules\n");
      exit(1);
  }
  
  /*****************************************************************
   *
***************
*** 1846,1855 ****
--- 1847,1866 ----
  	*/
      }
  
  } /* standalone_main */
  
+ void show_modules()
+ {
+     extern char *preloaded_module_names[];
+     int t;
+ 
+     printf ("Compiled-in modules:\n");
+     for (t = 0; preloaded_module_names[t]; ++t)
+       printf ("  %s\n", preloaded_module_names[t]);
+ }
+ 
  extern char *optarg;
  extern int optind;
  
  int
  main(int argc, char *argv[])
***************
*** 1876,1886 ****
      
      server_argv0 = argv[0];
      strcpy (server_root, HTTPD_ROOT);
      strcpy (server_confname, SERVER_CONFIG_FILE);
  
!     while((c = getopt(argc,argv,"Xd:f:vh")) != -1) {
          switch(c) {
            case 'd':
              strcpy (server_root, optarg);
              break;
            case 'f':
--- 1887,1897 ----
      
      server_argv0 = argv[0];
      strcpy (server_root, HTTPD_ROOT);
      strcpy (server_confname, SERVER_CONFIG_FILE);
  
!     while((c = getopt(argc,argv,"Xd:f:vhl")) != -1) {
          switch(c) {
            case 'd':
              strcpy (server_root, optarg);
              break;
            case 'f':
***************
*** 1889,1898 ****
--- 1900,1912 ----
            case 'v':
              printf("Server version %s.\n",SERVER_VERSION);
              exit(0);
            case 'h':
  	    show_directives();
+ 	    exit(0);
+ 	  case 'l':
+ 	    show_modules();
  	    exit(0);
  	  case 'X':
  	    ++one_process;	/* Weird debugging mode. */
  	    break;
            case '?':
Index: mod_info.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_info.c,v
retrieving revision 1.3
diff -c -5 -r1.3 mod_info.c
*** mod_info.c	1996/08/20 11:51:13	1.3
--- mod_info.c	1996/10/16 15:28:55
***************
*** 235,246 ****
  }
  
  int display_info(request_rec *r) {
  	module *modp = NULL;
  	char buf[256];
!     extern char *module_names[];
!     char **names = module_names;
  	command_rec *cmd=NULL;
  	handler_rec *hand=NULL;
  	server_rec *serv = r->server;
  	int comma=0;
  	mod_info_config_lines *mod_info_cfg_httpd=NULL;
--- 235,245 ----
  }
  
  int display_info(request_rec *r) {
  	module *modp = NULL;
  	char buf[256];
! 	char *name;
  	command_rec *cmd=NULL;
  	handler_rec *hand=NULL;
  	server_rec *serv = r->server;
  	int comma=0;
  	mod_info_config_lines *mod_info_cfg_httpd=NULL;
***************
*** 277,288 ****
  		mod_info_cfg_srm = mod_info_load_config(r->pool,buf);
  		sprintf(buf,"%s/%s",server_root,serv->access_confname);
  		mod_info_cfg_access = mod_info_load_config(r->pool,buf);
  		if(!r->args) {
  			rputs("<tt><a href=\"#server\">Server Settings</a>, ",r);
! 			for(modp = top_module, names=module_names; modp; modp = modp->next, names++) {
! 				sprintf(buf,"<a href=\"#%s\">%s</a>",*names,*names);
  				rputs(buf, r);
  				if(modp->next) rputs(", ",r);
  			}
  			rputs("</tt><hr>",r);
  
--- 276,288 ----
  		mod_info_cfg_srm = mod_info_load_config(r->pool,buf);
  		sprintf(buf,"%s/%s",server_root,serv->access_confname);
  		mod_info_cfg_access = mod_info_load_config(r->pool,buf);
  		if(!r->args) {
  			rputs("<tt><a href=\"#server\">Server Settings</a>, ",r);
! 			for(modp = top_module; modp; modp = modp->next) {
! 			        name=find_module_name (modp);
! 				sprintf(buf,"<a href=\"#%s\">%s</a>",name,name);
  				rputs(buf, r);
  				if(modp->next) rputs(", ",r);
  			}
  			rputs("</tt><hr>",r);
  
***************
*** 312,324 ****
  			rputs(buf,r);
  			sprintf(buf,"<strong>Scoreboard File:</strong> <tt>%s</tt><br>\n",scoreboard_fname);
  			rputs(buf,r);
  		}
  		rputs("<hr><dl>",r);
! 		for(modp = top_module, names=module_names; modp; modp = modp->next, names++) {
! 			if(!r->args || !strcasecmp(*names,r->args)) {	
! 				sprintf(buf,"<dt><a name=\"%s\"><strong>Module Name:</strong> <font size=+1><tt>%s</tt></a></font>\n",*names,*names);
  				rputs(buf,r);
  				rputs("<dt><strong>Content-types affected:</strong>",r);	
  				hand = modp->handlers;
  				if(hand) {
  					while(hand) {
--- 312,325 ----
  			rputs(buf,r);
  			sprintf(buf,"<strong>Scoreboard File:</strong> <tt>%s</tt><br>\n",scoreboard_fname);
  			rputs(buf,r);
  		}
  		rputs("<hr><dl>",r);
! 		for(modp = top_module; modp; modp = modp->next) {
! 		        name=find_module_name (modp);
! 			if(!r->args || !strcasecmp(name,r->args)) {	
! 				sprintf(buf,"<dt><a name=\"%s\"><strong>Module Name:</strong> <font size=+1><tt>%s</tt></a></font>\n",name,name);
  				rputs(buf,r);
  				rputs("<dt><strong>Content-types affected:</strong>",r);	
  				hand = modp->handlers;
  				if(hand) {
  					while(hand) {
***************
*** 392,403 ****
  				if(r->args) break;
  			}
  		}
  		if(!modp && r->args && strcasecmp(r->args,"server")) rputs("<b>No such module</b>\n",r);
  	} else {
! 		for(modp = top_module; modp; modp = modp->next, names++) {
! 			rputs(*names,r);
  			if(modp->next) rputs("<br>",r);
  		}	
  	}	
  	rputs("</dl></body></html>\n",r);
  	/* Done, turn off timeout, close file and return */
--- 393,405 ----
  				if(r->args) break;
  			}
  		}
  		if(!modp && r->args && strcasecmp(r->args,"server")) rputs("<b>No such module</b>\n",r);
  	} else {
! 		for(modp = top_module; modp; modp = modp->next) {
! 		        name=find_module_name (modp);
! 			rputs(name,r);
  			if(modp->next) rputs("<br>",r);
  		}	
  	}	
  	rputs("</dl></body></html>\n",r);
  	/* Done, turn off timeout, close file and return */

Re: addmodule revisited

Posted by Tom Tromey <tr...@creche.cygnus.com>.
Brian> Tom, if you could pull down a snapshot from the tree and test
Brian> it in your environment just to make sure, that would be swell.

I ran it against my test suite, and it worked sufficiently well (my
test suite still assumes that responses will be "HTTP/1.0", so 1.2
failed all those checks).

Tom
-- 
tromey@cygnus.com                 Member, League for Programming Freedom

Re: addmodule revisited

Posted by Brian Behlendorf <br...@organic.com>.
D'oh!  I didn't realize the patch modified Configure, so when I reran
./Configure I guess the new makefile and modules.c which it created handled the
problem.  Since there was general consensus that this would be a Good Thing for
1.2, and since Tom's tested it in his environments pretty thoroughly, I've
committed it.  

Tom, if you could pull down a snapshot from the tree and test it in your
environment just to make sure, that would be swell.

	Brian

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com  www.apache.org  hyperreal.com  http://www.organic.com/JOBS


Re: addmodule revisited

Posted by Brian Behlendorf <br...@organic.com>.
I tried implementing this patch, but got

http_main.o: Undefined symbol _preloaded_module_names referenced from text segment
http_main.o: Undefined symbol _preloaded_module_names referenced from text segment
http_config.o: Undefined symbol _preloaded_modules referenced from text segment
http_config.o: Undefined symbol _preloaded_modules referenced from text segment
http_config.o: Undefined symbol _preloaded_module_names referenced from text segment
http_config.o: Undefined symbol _preloaded_module_names referenced from text segment
http_config.o: Undefined symbol _preloaded_module_names referenced from text segment
http_config.o: Undefined symbol _preloaded_modules referenced from text segment
*** Error code 1

at link time.  Could you have left out a change to a .h file?  

This could be related to the recent constification of the code - you should
pull down a recent CVS snapshot and generate the patch from that to make sure
it works fine.  I had to hand-patch one part of the patch you submitted.

Otherwise, I think there's general consensus this should go in. 

	Brian

On 16 Oct 1996, Tom Tromey wrote:
> My previous AddModule patch had a serious bug.  I forget the precise
> symptoms, but basically it had to do with various arrays (eg
> conf_vector) not being sized properly.
> 
> I have a new version of the patch that fixes this.  This patch
> slightly changes the meaning module_index; whereas module_index used
> to be the location of the module in the module list, it is now just
> the index at which the module is linked in.
> 
> I also changed the default module_index in STANDARD_MODULE_STUFF to be
> -1 instead of 0.  This change is not really necessary, but I thought
> it didn't really make sense for the default value to be a valid index.
> 
> Changing the module_index makes find_module_name constant time.
> 
> It is also now an error if AddModule can't find the named module.
> 
> BTW I noticed that mod_info is inherently broken if you are using
> mod_dld (this is true with or without the AddModule patch).  If you
> load a module using mod_dld there is no way to get its name.  Another
> reason the module name should go in the module structure, I guess.
> 
> The patch is appended.  It is also available for ftp from
> ftp.cygnus.com in pub/tromey.  I tested this patch by running the
> modified Apache against my test suite.

--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
brian@organic.com  www.apache.org  hyperreal.com  http://www.organic.com/JOBS