[dovecot-cvs] dovecot/src/lib module-dir.c, 1.27, 1.28 module-dir.h, 1.7, 1.8
tss at dovecot.org
tss at dovecot.org
Fri Feb 16 13:12:17 UTC 2007
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv5379/lib
Modified Files:
module-dir.c module-dir.h
Log Message:
module_dir_load() doesn't call init() functions anymore. Added a new
module_dir_init() which does it. This way imap/pop3 can load the modules
before chrooting and initialize them after.
Index: module-dir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- module-dir.c 21 Dec 2006 15:53:56 -0000 1.27
+++ module-dir.c 16 Feb 2007 13:12:15 -0000 1.28
@@ -86,7 +86,6 @@
module_load(const char *path, const char *name, bool require_init_funcs)
{
void *handle;
- void (*init)(void);
struct module *module;
handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW);
@@ -101,14 +100,17 @@
module->handle = handle;
/* get our init func */
- init = (void (*)(void))
+ module->init = (void (*)(void))
get_symbol(module, t_strconcat(name, "_init", NULL),
!require_init_funcs);
- module->deinit = init == NULL ? NULL : (void (*)(void))
+ module->deinit = module->init == NULL ? NULL : (void (*)(void))
get_symbol(module, t_strconcat(name, "_deinit", NULL),
!require_init_funcs);
- if ((init == NULL || module->deinit == NULL) && require_init_funcs) {
+ if ((module->init == NULL || module->deinit == NULL) &&
+ require_init_funcs) {
+ i_error("Module doesn't have %s function: %s",
+ module->init == NULL ? "init" : "deinit", path);
module->deinit = NULL;
module_free(module);
return NULL;
@@ -116,9 +118,6 @@
if (getenv("DEBUG") != NULL)
i_info("Module loaded: %s", path);
-
- if (init != NULL)
- init();
return module;
}
@@ -275,6 +274,16 @@
return modules;
}
+void module_dir_init(struct module *modules)
+{
+ struct module *module;
+
+ for (module = modules; module != NULL; module = module->next) {
+ if (module->init != NULL)
+ module->init();
+ }
+}
+
void module_dir_deinit(struct module *modules)
{
struct module *module;
Index: module-dir.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- module-dir.h 12 Apr 2006 14:04:55 -0000 1.7
+++ module-dir.h 16 Feb 2007 13:12:15 -0000 1.8
@@ -5,6 +5,7 @@
char *path, *name;
void *handle;
+ void (*init)(void);
void (*deinit)(void);
struct module *next;
@@ -14,6 +15,8 @@
module names to load, or NULL to load everything. */
struct module *module_dir_load(const char *dir, const char *module_names,
bool require_init_funcs);
+/* Call init() in all modules */
+void module_dir_init(struct module *modules);
/* Call deinit() in all modules and mark them NULL so module_dir_unload()
won't do it again. */
void module_dir_deinit(struct module *modules);
More information about the dovecot-cvs
mailing list