[dovecot-cvs] dovecot/src/lib module-dir.c,1.19.2.5,1.19.2.6
tss at dovecot.org
tss at dovecot.org
Fri Feb 16 17:55:42 UTC 2007
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv14645
Modified Files:
Tag: branch_1_0
module-dir.c
Log Message:
module_dir_init() was calling the init() functions in reverse order.
Index: module-dir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.c,v
retrieving revision 1.19.2.5
retrieving revision 1.19.2.6
diff -u -d -r1.19.2.5 -r1.19.2.6
--- module-dir.c 16 Feb 2007 13:12:03 -0000 1.19.2.5
+++ module-dir.c 16 Feb 2007 17:55:39 -0000 1.19.2.6
@@ -180,7 +180,7 @@
struct dirent *d;
const char *name, *path, *p, *stripped_name, **names_p;
const char **module_names_arr;
- struct module *modules, *module;
+ struct module *modules, *module, **module_pos;
unsigned int i, count;
array_t ARRAY_DEFINE(names, const char *);
pool_t pool;
@@ -236,6 +236,8 @@
module_file_get_name(module_names_arr[i]);
}
}
+
+ module_pos = &modules;
for (i = 0; i < count; i++) {
const char *name = names_p[i];
@@ -253,8 +255,8 @@
t_pop();
if (module != NULL) {
- module->next = modules;
- modules = module;
+ *module_pos = module;
+ module_pos = &module->next;
}
}
if (module_names_arr != NULL) {
@@ -287,14 +289,27 @@
void module_dir_deinit(struct module *modules)
{
- struct module *module;
+ struct module *module, **rev;
+ unsigned int i, count = 0;
+
+ for (module = modules; module != NULL; module = module->next)
+ count++;
+
+ /* @UNSAFE: deinitialize in reverse order */
+ t_push();
+ rev = t_new(struct module *, count);
+ for (i = 0, module = modules; i < count; i++, module = module->next)
+ rev[count-i-1] = module;
+
+ for (i = 0; i < count; i++) {
+ module = rev[i];
- for (module = modules; module != NULL; module = module->next) {
if (module->deinit != NULL) {
module->deinit();
module->deinit = NULL;
}
}
+ t_pop();
}
void module_dir_unload(struct module **modules)
More information about the dovecot-cvs
mailing list