From c052589bb3062e8739146d61855ef6bd76ecfea7 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Wed, 17 Aug 2005 09:56:33 +0000 Subject: [PATCH] load mod_indexfile before, mod_fastcgi and friends and let array regenerated unique ids if necessary git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@560 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/array.c | 3 ++- src/array.h | 1 + src/configfile-glue.c | 8 ++++++-- src/configfile.c | 13 +++++++------ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/array.c b/src/array.c index 16ecfb4e..7605fcdd 100644 --- a/src/array.c +++ b/src/array.c @@ -28,6 +28,7 @@ array *array_init_array(array *src) { a->size = src->size; a->next_power_of_2 = src->next_power_of_2; a->unique_ndx = src->unique_ndx; + a->is_array = src->is_array; a->data = malloc(sizeof(*src->data) * src->size); for (i = 0; i < src->size; i++) { @@ -168,10 +169,10 @@ int array_insert_unique(array *a, data_unset *str) { /* generate unique index if neccesary */ if (str->key->used == 0) { buffer_copy_long(str->key, a->unique_ndx++); + a->is_array = 1; } /* try to find the string */ - if (-1 != (ndx = array_get_index(a, str->key->ptr, str->key->used, &pos))) { /* found, leave here */ if (a->data[ndx]->type == str->type) { diff --git a/src/array.h b/src/array.h index c52732d2..c072b540 100644 --- a/src/array.h +++ b/src/array.h @@ -33,6 +33,7 @@ typedef struct { size_t size; size_t unique_ndx; + int is_array; /* 0 if it is a hash, 1 for array (autogenerated keys) */ size_t next_power_of_2; int is_weakref; /* data is weakref, don't bother the data */ diff --git a/src/configfile-glue.c b/src/configfile-glue.c index c4c4c4ee..2f400476 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -1,4 +1,3 @@ - #include "base.h" #include "buffer.h" #include "array.h" @@ -43,7 +42,12 @@ int config_insert_values_internal(server *srv, array *ca, const config_values_t data_string *ds = data_string_init(); buffer_copy_string_buffer(ds->value, ((data_string *)(da->value->data[j]))->value); - buffer_copy_string_buffer(ds->key, ((data_string *)(da->value->data[j]))->key); + if (!da->value->is_array) { + /* the id's were generated automaticly, as we copy now we might have to renumber them + * this is used to prepend server.modules by mod_indexfiles as it has to be loaded + * before mod_fastcgi and friends */ + buffer_copy_string_buffer(ds->key, ((data_string *)(da->value->data[j]))->key); + } array_insert_unique(cv[i].destination, (data_unset *)ds); } else { diff --git a/src/configfile.c b/src/configfile.c index 537de673..a3a02f4d 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -117,6 +117,13 @@ static int config_insert(server *srv) { assert(srv->config_storage); + /* prepend default modules */ + if (NULL == array_get_element(srv->srvconf.modules, "mod_indexfile")) { + ds = data_string_init(); + buffer_copy_string(ds->value, "mod_indexfile"); + array_insert_unique(srv->srvconf.modules, (data_unset *)ds); + } + for (i = 0; i < srv->config_context->used; i++) { specific_config *s; @@ -207,12 +214,6 @@ static int config_insert(server *srv) { srv->srvconf.modules->unique_ndx = srv->srvconf.modules->used; /* append default modules */ - if (NULL == array_get_element(srv->srvconf.modules, "mod_indexfile")) { - ds = data_string_init(); - buffer_copy_string(ds->value, "mod_indexfile"); - array_insert_unique(srv->srvconf.modules, (data_unset *)ds); - } - if (NULL == array_get_element(srv->srvconf.modules, "mod_dirlisting")) { ds = data_string_init(); buffer_copy_string(ds->value, "mod_dirlisting");