mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Use RedisModuleString for OnLoad argv.
This commit is contained in:
parent
2bd13cf0eb
commit
cc58f11ccc
@ -155,13 +155,13 @@ void resetServerSaveParams(void) {
|
||||
|
||||
void queueLoadModule(sds path, sds *argv, int argc)
|
||||
{
|
||||
struct loadmodule *loadmod = zmalloc(sizeof(struct loadmodule)+sizeof(sds)*argc);
|
||||
struct loadmodule *loadmod = zmalloc(sizeof(struct loadmodule)+sizeof(robj*)*argc);
|
||||
int i;
|
||||
|
||||
loadmod->path = sdsnew(path);
|
||||
loadmod->argc = argc;
|
||||
for (i = 0; i < argc; i++) {
|
||||
loadmod->argv[i] = sdsnew(argv[i]);
|
||||
loadmod->argv[i] = createStringObject(argv[i],sdslen(argv[i]));
|
||||
}
|
||||
listAddNodeTail(server.loadmodule_queue,loadmod);
|
||||
}
|
||||
|
10
src/module.c
10
src/module.c
@ -3011,16 +3011,12 @@ void moduleCommand(client *c) {
|
||||
char *subcmd = c->argv[1]->ptr;
|
||||
|
||||
if (!strcasecmp(subcmd,"load") && c->argc >= 3) {
|
||||
sds *argv = NULL;
|
||||
robj **argv = NULL;
|
||||
int argc = 0;
|
||||
int i;
|
||||
|
||||
if (c->argc > 3) {
|
||||
argc = c->argc - 3;
|
||||
argv = zmalloc(sizeof(sds)*argc);
|
||||
for (i=0; i<argc; i++) {
|
||||
argv[i] = (sds) c->argv[i+3]->ptr;
|
||||
}
|
||||
argv = &c->argv[3];
|
||||
}
|
||||
|
||||
if (moduleLoad(c->argv[2]->ptr,(void **)argv,argc) == C_OK)
|
||||
@ -3028,8 +3024,6 @@ void moduleCommand(client *c) {
|
||||
else
|
||||
addReplyError(c,
|
||||
"Error loading the extension. Please check the server logs.");
|
||||
if (argv)
|
||||
zfree(argv);
|
||||
} else if (!strcasecmp(subcmd,"unload") && c->argc == 3) {
|
||||
if (moduleUnload(c->argv[2]->ptr) == C_OK)
|
||||
addReply(c,shared.ok);
|
||||
|
@ -686,7 +686,7 @@ struct saveparam {
|
||||
struct loadmodule {
|
||||
sds path;
|
||||
int argc;
|
||||
sds argv[];
|
||||
robj *argv[];
|
||||
};
|
||||
|
||||
struct sharedObjectsStruct {
|
||||
|
Loading…
Reference in New Issue
Block a user