diff options
author | Alfred E. Heggestad <alfred.heggestad@gmail.com> | 2017-06-10 09:49:12 +0200 |
---|---|---|
committer | Alfred E. Heggestad <alfred.heggestad@gmail.com> | 2017-06-10 09:49:12 +0200 |
commit | e112c7ea48be42d00169a57562420fbabd9f749e (patch) | |
tree | 43b8a140e5d21834c9a6e265a1cd031e2f521f34 /src | |
parent | 3af1048b8dee630b006081e2306bc621d5cec489 (diff) |
module: check if static module is already loaded
Diffstat (limited to 'src')
-rw-r--r-- | src/module.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/module.c b/src/module.c index 3c74014..614f18d 100644 --- a/src/module.c +++ b/src/module.c @@ -33,7 +33,7 @@ static void modapp_destructor(void *arg) /* Declared in static.c */ extern const struct mod_export *mod_table[]; -static const struct mod_export *find_module(const struct pl *pl) +static const struct mod_export *lookup_static_module(const struct pl *pl) { struct pl name; uint32_t i; @@ -58,6 +58,7 @@ static int load_module(struct mod **modp, const struct pl *modpath, const struct pl *name) { char file[FS_PATH_MAX]; + char namestr[256]; struct mod *m = NULL; int err = 0; @@ -66,9 +67,18 @@ static int load_module(struct mod **modp, const struct pl *modpath, #ifdef STATIC /* Try static first */ - err = mod_add(&m, find_module(name)); + pl_strcpy(name, namestr, sizeof(namestr)); + + if (mod_find(namestr)) { + info("static module already loaded: %r\n", name); + return EALREADY; + } + + err = mod_add(&m, lookup_static_module(name)); if (!err) goto out; +#else + (void)namestr; #endif /* Then dynamic */ |