Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,9 @@ static void MR_ConnectToShard(Node* n){
return;
}
if (c->err) {
/* Let *c leak for now... */
/* Connection context was created but is in an error state - free it. */
RedisModule_Log(mr_staticCtx, "warning", "Error: %s\n", c->errstr);
redisAsyncFree(c);
return;
}
c->data = n;
Expand Down Expand Up @@ -1335,10 +1336,13 @@ int MR_ClusterInnerCommunicationMsg(RedisModuleCtx *ctx, RedisModuleString **arg
return RedisModule_WrongArity(ctx);
}

// we must copy argv because if the client will disconnect the redis will free it
/* We must copy argv because this command defers processing to the LibMR
* event-loop thread. Using RedisModule_HoldString() here is unsafe: strings
* originating from client command arguments may share the client's query
* buffer, which Redis can trim/realloc after the command returns. */
RedisModuleString **argvNew = MR_ALLOC(sizeof(RedisModuleString *) * argc);
for(size_t i = 0 ; i < argc ; ++i){
argvNew[i] = RedisModule_HoldString(NULL, argv[i]);
argvNew[i] = RedisModule_CreateStringFromString(NULL, argv[i]);
}

MessageCtx* msgCtx = MR_ALLOC(sizeof(*msgCtx));
Expand Down
Loading