diff options
Diffstat (limited to 'valkey-loadmod.patch')
| -rw-r--r-- | valkey-loadmod.patch | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/valkey-loadmod.patch b/valkey-loadmod.patch index dad9cb9..74c016e 100644 --- a/valkey-loadmod.patch +++ b/valkey-loadmod.patch @@ -1,4 +1,4 @@ -From b40ab88996d0bbe9bdd366af9426f7400b21e19c Mon Sep 17 00:00:00 2001 +From cae829f497550d175331d3d6cd0bbf4aed0965a4 Mon Sep 17 00:00:00 2001 From: Remi Collet <remi@remirepo.net> Date: Sat, 4 Oct 2025 07:23:52 +0200 Subject: [PATCH] Fix #2678 don't add loadmodule when from config @@ -10,13 +10,14 @@ Signed-off-by: Remi Collet <remi@remirepo.net> src/config.c | 8 ++++++-- src/module.c | 17 ++++++++++++----- src/module.h | 4 ++-- - 3 files changed, 20 insertions(+), 9 deletions(-) + src/server.c | 2 +- + 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/config.c b/src/config.c -index d0158b2c4d..ab453056df 100644 +index 93ef289e3..dc4116383 100644 --- a/src/config.c +++ b/src/config.c -@@ -448,6 +448,8 @@ static int updateClientOutputBufferLimit(sds *args, int arg_len, const char **er +@@ -450,6 +450,8 @@ static int updateClientOutputBufferLimit(sds *args, int arg_len, const char **er * within conf file parsing. This is only needed to support the deprecated * abnormal aggregate `save T C` functionality. Remove in the future. */ static int reading_config_file; @@ -25,7 +26,7 @@ index d0158b2c4d..ab453056df 100644 void loadServerConfigFromString(sds config) { deprecatedConfig deprecated_configs[] = { -@@ -539,7 +541,9 @@ void loadServerConfigFromString(sds config) { +@@ -541,7 +543,9 @@ void loadServerConfigFromString(sds config) { /* Execute config directives */ if (!strcasecmp(argv[0], "include") && argc == 2) { @@ -35,7 +36,7 @@ index d0158b2c4d..ab453056df 100644 } else if (!strcasecmp(argv[0], "rename-command") && argc == 3) { struct serverCommand *cmd = lookupCommandBySds(argv[1]); -@@ -572,7 +576,7 @@ void loadServerConfigFromString(sds config) { +@@ -574,7 +578,7 @@ void loadServerConfigFromString(sds config) { goto loaderr; } } else if (!strcasecmp(argv[0], "loadmodule") && argc >= 2) { @@ -44,7 +45,7 @@ index d0158b2c4d..ab453056df 100644 } else if (strchr(argv[0], '.')) { if (argc < 2) { err = "Module config specified without value"; -@@ -1605,7 +1609,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) { +@@ -1618,7 +1622,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) { while ((de = dictNext(di)) != NULL) { struct ValkeyModule *module = dictGetVal(de); line = moduleLoadQueueEntryToLoadmoduleOptionStr(module, "loadmodule"); @@ -54,7 +55,7 @@ index d0158b2c4d..ab453056df 100644 dictReleaseIterator(di); /* Mark "loadmodule" as processed in case modules is empty. */ diff --git a/src/module.c b/src/module.c -index e5afa952fa..f18bc3c6bf 100644 +index de5a5510e..2638268e1 100644 --- a/src/module.c +++ b/src/module.c @@ -84,6 +84,7 @@ @@ -65,7 +66,7 @@ index e5afa952fa..f18bc3c6bf 100644 int argc; robj **argv; }; -@@ -670,7 +671,7 @@ void freeClientModuleData(client *c) { +@@ -679,7 +680,7 @@ void freeClientModuleData(client *c) { c->module_data = NULL; } @@ -74,7 +75,7 @@ index e5afa952fa..f18bc3c6bf 100644 int i; struct moduleLoadQueueEntry *loadmod; -@@ -678,6 +679,7 @@ void moduleEnqueueLoadModule(sds path, sds *argv, int argc) { +@@ -687,6 +688,7 @@ void moduleEnqueueLoadModule(sds path, sds *argv, int argc) { loadmod->argv = argc ? zmalloc(sizeof(robj *) * argc) : NULL; loadmod->path = sdsnew(path); loadmod->argc = argc; @@ -82,7 +83,7 @@ index e5afa952fa..f18bc3c6bf 100644 for (i = 0; i < argc; i++) { loadmod->argv[i] = createRawStringObject(argv[i], sdslen(argv[i])); } -@@ -688,6 +690,10 @@ sds moduleLoadQueueEntryToLoadmoduleOptionStr(ValkeyModule *module, +@@ -697,6 +699,10 @@ sds moduleLoadQueueEntryToLoadmoduleOptionStr(ValkeyModule *module, const char *config_option_str) { sds line; @@ -93,7 +94,7 @@ index e5afa952fa..f18bc3c6bf 100644 line = sdsnew(config_option_str); line = sdscatlen(line, " ", 1); line = sdscatsds(line, module->loadmod->path); -@@ -12350,7 +12356,7 @@ void moduleLoadFromQueue(void) { +@@ -12629,7 +12635,7 @@ void moduleLoadFromQueue(void) { listRewind(server.loadmodule_queue, &li); while ((ln = listNext(&li))) { struct moduleLoadQueueEntry *loadmod = ln->value; @@ -102,7 +103,7 @@ index e5afa952fa..f18bc3c6bf 100644 serverLog(LL_WARNING, "Can't load module from %s: server aborting", loadmod->path); exit(1); } -@@ -12531,7 +12537,7 @@ void moduleUnregisterCleanup(ValkeyModule *module) { +@@ -12818,7 +12824,7 @@ void moduleUnregisterCleanup(ValkeyModule *module) { /* Load a module and initialize it. On success C_OK is returned, otherwise * C_ERR is returned. */ @@ -111,7 +112,7 @@ index e5afa952fa..f18bc3c6bf 100644 int (*onload)(void *, void **, int); void *handle; -@@ -12606,6 +12612,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa +@@ -12893,6 +12899,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa ctx.module->loadmod->path = sdsnew(path); ctx.module->loadmod->argv = module_argc ? zmalloc(sizeof(robj *) * module_argc) : NULL; ctx.module->loadmod->argc = module_argc; @@ -119,26 +120,26 @@ index e5afa952fa..f18bc3c6bf 100644 for (int i = 0; i < module_argc; i++) { ctx.module->loadmod->argv[i] = module_argv[i]; incrRefCount(ctx.module->loadmod->argv[i]); -@@ -13529,7 +13536,7 @@ void moduleCommand(client *c) { +@@ -13961,7 +13968,7 @@ void moduleCommand(client *c) { argv = &c->argv[3]; } -- if (moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 0) == C_OK) -+ if (moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 0, 0) == C_OK) +- if (moduleLoad(objectGetVal(c->argv[2]), (void **)argv, argc, 0) == C_OK) ++ if (moduleLoad(objectGetVal(c->argv[2]), (void **)argv, argc, 0, 0) == C_OK) addReply(c, shared.ok); else addReplyError(c, "Error loading the extension. Please check the server logs."); -@@ -13544,7 +13551,7 @@ void moduleCommand(client *c) { +@@ -13976,7 +13983,7 @@ void moduleCommand(client *c) { /* If this is a loadex command we want to populate server.module_configs_queue with * sds NAME VALUE pairs. We also want to increment argv to just after ARGS, if supplied. */ if (parseLoadexArguments((ValkeyModuleString ***)&argv, &argc) == VALKEYMODULE_OK && -- moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK) -+ moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1, 0) == C_OK) +- moduleLoad(objectGetVal(c->argv[2]), (void **)argv, argc, 1) == C_OK) ++ moduleLoad(objectGetVal(c->argv[2]), (void **)argv, argc, 1, 0) == C_OK) addReply(c, shared.ok); else { dictEmpty(server.module_configs_queue, NULL); diff --git a/src/module.h b/src/module.h -index f6c266b592..1f9e729e56 100644 +index c7ad384c6..3b12efbaf 100644 --- a/src/module.h +++ b/src/module.h @@ -169,7 +169,7 @@ static inline void moduleInitDigestContext(ValkeyModuleDigest *mdvar) { @@ -150,12 +151,28 @@ index f6c266b592..1f9e729e56 100644 sds moduleLoadQueueEntryToLoadmoduleOptionStr(ValkeyModule *module, const char *config_option_str); ValkeyModuleCtx *moduleAllocateContext(void); -@@ -180,7 +180,7 @@ void moduleFreeContext(ValkeyModuleCtx *ctx); +@@ -181,7 +181,7 @@ void moduleFreeContext(ValkeyModuleCtx *ctx); void moduleInitModulesSystem(void); void moduleInitModulesSystemLast(void); void modulesCron(void); -int moduleLoad(const char *path, void **argv, int argc, int is_loadex); +int moduleLoad(const char *path, void **argv, int argc, int is_loadex, int from_include); int moduleUnload(sds name, const char **errmsg); + void moduleUnloadAllModules(void); void moduleLoadFromQueue(void); - int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result); +diff --git a/src/server.c b/src/server.c +index 881d83bad..a21d3ca9e 100644 +--- a/src/server.c ++++ b/src/server.c +@@ -7630,7 +7630,7 @@ __attribute__((weak)) int main(int argc, char **argv) { + #ifdef LUA_ENABLED + #define LUA_LIB_STR STRINGIFY(LUA_LIB) + if (scriptingEngineManagerFind("lua") == NULL) { +- if (moduleLoad(LUA_LIB_STR, NULL, 0, 0) != C_OK) { ++ if (moduleLoad(LUA_LIB_STR, NULL, 0, 0, 1) != C_OK) { + serverPanic("Lua engine initialization failed, check the server logs."); + } + } +-- +2.53.0 + |
