[dovecot-cvs] dovecot/src/lib module-dir.c, 1.19.2.4, 1.19.2.5 module-dir.h, 1.7, 1.7.2.1
tss at dovecot.org
tss at dovecot.org
Fri Feb 16 13:12:07 UTC 2007
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv5370/lib
Modified Files:
Tag: branch_1_0
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.19.2.4
retrieving revision 1.19.2.5
diff -u -d -r1.19.2.4 -r1.19.2.5
--- module-dir.c 21 Dec 2006 15:53:55 -0000 1.19.2.4
+++ module-dir.c 16 Feb 2007 13:12:03 -0000 1.19.2.5
@@ -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;
}
@@ -276,6 +275,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.7.2.1
diff -u -d -r1.7 -r1.7.2.1
--- module-dir.h 12 Apr 2006 14:04:55 -0000 1.7
+++ module-dir.h 16 Feb 2007 13:12:03 -0000 1.7.2.1
@@ -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