Use RedisModuleString for OnLoad argv.

This commit is contained in:
Yossi Gottlieb 2016-06-05 13:18:24 +03:00
parent 2bd13cf0eb
commit cc58f11ccc
3 changed files with 5 additions and 11 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -686,7 +686,7 @@ struct saveparam {
struct loadmodule {
sds path;
int argc;
sds argv[];
robj *argv[];
};
struct sharedObjectsStruct {