Skip to content

Commit 22897c1

Browse files
committed
broker: load module with DSO version extension
Problem: currently when a module is loaded by name, only "name.so" matches, while "name.so.0.0.0" does not. Match "name.so*" so that a DSO can be found with or without suffixes. The first match is used. Fixes #5255
1 parent 38cd455 commit 22897c1

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/broker/broker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ static int mod_svc_cb (const flux_msg_t *msg, void *arg)
11901190
}
11911191

11921192
/* Load broker module.
1193-
* 'name' is the name to use for the module (NULL = use dso basename minus .so)
1193+
* 'name' is the name to use for the module (NULL = use dso basename minus ext)
11941194
* 'path' is either a dso path or a dso basename (e.g. "kvs" or "/a/b/kvs.so".
11951195
*/
11961196
static int load_module (broker_ctx_t *ctx,
@@ -1211,7 +1211,7 @@ static int load_module (broker_ctx_t *ctx,
12111211
errno = EINVAL;
12121212
return -1;
12131213
}
1214-
if (asprintf (&pattern, "%s.so", path) < 0) {
1214+
if (asprintf (&pattern, "%s.so*", path) < 0) {
12151215
errprintf (error, "out of memory");
12161216
return -1;
12171217
}

src/broker/module.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,13 @@ flux_msg_t *module_pop_insmod (module_t *p)
549549
static char *module_name_from_path (const char *s)
550550
{
551551
char *path, *name, *cpy;
552+
char *cp;
552553

553554
if (!(path = strdup (s))
554555
|| !(name = basename (path)))
555556
goto error;
556-
557-
int n = strlen (name);
558-
if (n > 3 && streq (&name[n - 3], ".so"))
559-
name[n - 3] = '\0';
560-
557+
if ((cp = strstr (name, ".so")))
558+
*cp = '\0';
561559
if (!(cpy = strdup (name)))
562560
goto error;
563561
free (path);

0 commit comments

Comments
 (0)