8484
8585struct moduleLoadQueueEntry {
8686    sds path;
87+     int conf;
8788    int argc;
8889    robj **argv;
8990};
@@ -678,6 +679,7 @@ void moduleEnqueueLoadModule(sds path, sds *argv, int argc) {
678679    loadmod->argv = argc ? zmalloc(sizeof(robj *) * argc) : NULL;
679680    loadmod->path = sdsnew(path);
680681    loadmod->argc = argc;
682+     loadmod->conf = 1;
681683    for (i = 0; i < argc; i++) {
682684        loadmod->argv[i] = createRawStringObject(argv[i], sdslen(argv[i]));
683685    }
@@ -688,6 +690,10 @@ sds moduleLoadQueueEntryToLoadmoduleOptionStr(ValkeyModule *module,
688690                                              const char *config_option_str) {
689691    sds line;
690692
693+     if (module->loadmod->conf) {
694+         /* no need to add as already from config */
695+         return NULL;
696+     }
691697    line = sdsnew(config_option_str);
692698    line = sdscatlen(line, " ", 1);
693699    line = sdscatsds(line, module->loadmod->path);
@@ -12350,7 +12356,7 @@ void moduleLoadFromQueue(void) {
1235012356    listRewind(server.loadmodule_queue, &li);
1235112357    while ((ln = listNext(&li))) {
1235212358        struct moduleLoadQueueEntry *loadmod = ln->value;
12353-         if (moduleLoad(loadmod->path, (void **)loadmod->argv, loadmod->argc, 0) == C_ERR) {
12359+         if (moduleLoad(loadmod->path, (void **)loadmod->argv, loadmod->argc, 0, 1 ) == C_ERR) {
1235412360            serverLog(LL_WARNING, "Can't load module from %s: server aborting", loadmod->path);
1235512361            exit(1);
1235612362        }
@@ -12531,7 +12537,7 @@ void moduleUnregisterCleanup(ValkeyModule *module) {
1253112537
1253212538/* Load a module and initialize it. On success C_OK is returned, otherwise
1253312539 * C_ERR is returned. */
12534- int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loadex) {
12540+ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loadex, int is_config ) {
1253512541    int (*onload)(void *, void **, int);
1253612542    void *handle;
1253712543
@@ -12606,6 +12612,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa
1260612612    ctx.module->loadmod->path = sdsnew(path);
1260712613    ctx.module->loadmod->argv = module_argc ? zmalloc(sizeof(robj *) * module_argc) : NULL;
1260812614    ctx.module->loadmod->argc = module_argc;
12615+     ctx.module->loadmod->conf = is_config;
1260912616    for (int i = 0; i < module_argc; i++) {
1261012617        ctx.module->loadmod->argv[i] = module_argv[i];
1261112618        incrRefCount(ctx.module->loadmod->argv[i]);
@@ -13529,7 +13536,7 @@ void moduleCommand(client *c) {
1352913536            argv = &c->argv[3];
1353013537        }
1353113538
13532-         if (moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 0) == C_OK)
13539+         if (moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 0, 0 ) == C_OK)
1353313540            addReply(c, shared.ok);
1353413541        else
1353513542            addReplyError(c, "Error loading the extension. Please check the server logs.");
@@ -13544,7 +13551,7 @@ void moduleCommand(client *c) {
1354413551        /* If this is a loadex command we want to populate server.module_configs_queue with
1354513552         * sds NAME VALUE pairs. We also want to increment argv to just after ARGS, if supplied. */
1354613553        if (parseLoadexArguments((ValkeyModuleString ***)&argv, &argc) == VALKEYMODULE_OK &&
13547-             moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK)
13554+             moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1, 0 ) == C_OK)
1354813555            addReply(c, shared.ok);
1354913556        else {
1355013557            dictEmpty(server.module_configs_queue, NULL);
0 commit comments