summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-30 10:14:27 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-30 10:14:27 +0200
commit16fdf8e19fe7a4a658d940a25d1a53c8d242f9fd (patch)
treee8712a0c1c5a145a8cc6501f6e4ab3c4cd1b8584 /src
parent6ae2376c5cd933ef37f810340eb38b073d0acca2 (diff)
module: use module-list from libre mod
needs this commit or later: https://github.com/creytiv/re/commit/9ca4ebb078d4b9b4c2b53775e2c011461d981130
Diffstat (limited to 'src')
-rw-r--r--src/module.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/module.c b/src/module.c
index 926b161..6c22c3a 100644
--- a/src/module.c
+++ b/src/module.c
@@ -8,26 +8,6 @@
#include "core.h"
-struct modapp {
- struct mod *mod;
- struct le le;
-};
-
-
-static struct list modappl;
-
-
-static void modapp_destructor(void *arg)
-{
- struct modapp *modapp = arg;
- const struct mod_export *me = mod_export(modapp->mod);
- if (me)
- debug("module: unloading app %s\n", me->name);
- list_unlink(&modapp->le);
- mem_deref(modapp->mod);
-}
-
-
#ifdef STATIC
/* Declared in static.c */
@@ -119,28 +99,21 @@ static int module_tmp_handler(const struct pl *val, void *arg)
static int module_app_handler(const struct pl *val, void *arg)
{
- struct modapp *modapp;
+ struct mod *mod = NULL;
const struct mod_export *me;
debug("module: loading app %r\n", val);
- modapp = mem_zalloc(sizeof(*modapp), modapp_destructor);
- if (!modapp)
- return ENOMEM;
-
- if (load_module(&modapp->mod, arg, val)) {
- mem_deref(modapp);
+ if (load_module(&mod, arg, val)) {
return 0;
}
- me = mod_export(modapp->mod);
+ me = mod_export(mod);
if (0 != str_casecmp(me->type, "application")) {
warning("module_app %r should be type application (%s)\n",
val, me->type);
}
- list_prepend(&modappl, &modapp->le, modapp);
-
return 0;
}
@@ -174,7 +147,20 @@ int module_init(const struct conf *conf)
void module_app_unload(void)
{
- list_flush(&modappl);
+ struct le *le = list_tail(mod_list());
+
+ /* unload in reverse order */
+ while (le) {
+ struct mod *mod = le->data;
+ const struct mod_export *me = mod_export(mod);
+
+ le = le->prev;
+
+ if (me && 0 == str_casecmp(me->type, "application")) {
+ debug("module: unloading app %s\n", me->name);
+ mem_deref(mod);
+ }
+ }
}