httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Hartill <r...@imdb.com>
Subject AddModule doesn't work correctly (fwd)
Date Thu, 11 Sep 1997 18:50:22 GMT

not acked

---------- Forwarded message ----------
Date: Thu, 11 Sep 1997 19:55:46 +0200
From: Xaver Fischer <xaver.fischer@munich.ixos.de>
To: "'apache-bugs@apache.org'" <apache-bugs@apache.org>
Subject: AddModule doesn't work correctly

Bug report

Summary: The configuration command "AddModule" is "executed" after
the configuration of module specific structures. Therefore for 
the added module these structures seems not to be initialized.

Hello,

first of all I like to say that the apache web server
is a very fine and a very generic software. Thank you for providing
such a professional software for free to the internet community.

Maybe I have found a bug in the source file "http_config.c" of
version 1.2.0, but I verified that there is no difference to the
version 1.2.4:
Let look at the following routines:

----------------------------------------------------------
server_rec *init_server_config(pool *p)
{
    server_rec *s = (server_rec *)pcalloc (p, sizeof (server_rec));

    s->port = DEFAULT_PORT;
    s->server_admin = DEFAULT_ADMIN;
    s->server_hostname = NULL;
    s->error_fname = DEFAULT_ERRORLOG;
    s->error_log = stderr;
    s->srm_confname = RESOURCE_CONFIG_FILE;
    s->access_confname = ACCESS_CONFIG_FILE;
    s->timeout = DEFAULT_TIMEOUT;
    s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
    s->keep_alive_max = DEFAULT_KEEPALIVE;
    s->keep_alive = 1;
    s->next = NULL;
    s->addrs = pcalloc(p, sizeof (server_addr_rec));
    s->addrs->host_addr.s_addr = htonl (INADDR_ANY); /* NOT virtual
host;
                           * don't match any real network
                           * interface.
                           */
    s->addrs->host_port = 0; /* matches any port */

    s->module_config = create_server_config (p, s);
    s->lookup_defaults = create_default_per_dir_config (p);

    return s;
}

server_rec *read_config(pool *p, pool *ptemp, char *confname)
{
    server_rec *s = init_server_config(p);

    init_config_globals(p);

    /* All server-wide config files now have the SAME syntax... */

    process_resource_config (s, confname, p, ptemp);
    process_resource_config (s, s->srm_confname, p, ptemp);
    process_resource_config (s, s->access_confname, p, ptemp);

    fixup_virtual_hosts (p, s);

    return s;
}
---------------------------------------------------------------------

In the first function "init_server()" the functions
"create_server_config()" and "create_default_per_dir_config()" 
are called. These functions execute the funtions for creating
per-directory and per-server config structures for 
every module in the modules list.

"init_server()" is called at the beginning of the function
"read_config()". Afterwards when reading the configuration with 
"process_resource_config()" the command "AddModule" will expand 
the list of prelinked modules. For some currently added module the 
configuration is not done.

This makes trouble e.g. in "directory_walk()" when calling
"merge_per_dir_config()".
"merge_per_dir_config()" sees that the module provides a 
merge per-dir function, but will call it with a NULL pointer 
for the "base_vector[module->index]".
 
In my eyes a solution would be to call the functions
"create_server_config()" and "create_default_per_dir_config()" 
after the reading of the configuration files.

To tell the whole story: The problems occurred at a changed version 
of the file "http_config.c". I replaced the function "add_module()" 
with the functions "add_module_in_order()" and "find_predecessor()":

---------------------------------
/*
 * XF: With apache 1.2 AddModules links the module to the top of
 * the list. But we want to add it at the position configured in
 * Configuration.tmpl. For the management of the currently active
modules there
 * exists a "linked list", where we have to insert the new module.
 * This function insert the module on the right position.
 */
void add_module_in_order (module *m)
{
    module *predecessor;

    if (m->version != MODULE_MAGIC_NUMBER) {
    fprintf(stderr, "httpd: module \"%s\" is not compatible with this "
                "version of Apache.\n", m->name);
    fprintf(stderr, "Please contact the author for the correct
version.\n");
    exit(1);
    }

    predecessor = find_predecessor(m->module_index);

    if(predecessor == NULL)
        add_module(m);
    else {
        if (m->next != NULL)
            fprintf(stderr, "Module configuration error:\n"
                        "The module structure seems to be corrupt!");

        m->next = predecessor->next;
        predecessor->next=m;
        num_modules++;
    }
}

/* XF: find the module with the least greater module_index */
module * find_predecessor(int index)
{
    module *tmp = top_module;
    if(!top_module) return NULL;
    if(top_module->module_index<index) return NULL;

    while (tmp->next && tmp->next->module_index>index)
        tmp=tmp->next;
    return tmp;
}
--------------------------------------------------------------------

I don't see any reason that there should be any difference concerning
the above described problem. In both cases ( if the module is added at
the top of the list or at some other position) the corresponding 
entries in the per-directory and per-server config structures 
are not initialized.
But maybe I didn't get the whole story.

Maybe you can use the two functions "add_module_in_order" and
"find_predecessor()" in some future version???

I hope someone finds some time to read this,

Thank you
Xaver Fischer



-------------------------------------------------------------------------
---
  Xaver Fischer
  Product Development
  iXOS Software AG        
  Bretonischer Ring 12        
  D-85630 Grasbrunn      

  Tel.: +49(0)89 46005 - 301
  Fax: +49(0)89 46005 -199
  Email: Xaver.Fischer@munich.ixos.de
-------------------------------------------------------------------------
---



Mime
View raw message