fix valgrind issues with recently added test in modules/blockonbackground (#9192)
fixes test issue introduced in #9167 1. invalid reads due to accessing non-retained string (passed as unblock context). 2. leaking module blocked client context, see #6922 for info. (cherry picked from commit a8518cce951629eaccde40fd0e51b36a5dc6321c)
This commit is contained in:
parent
79fa5618f1
commit
de1b19ea88
@ -206,6 +206,7 @@ int Block_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||||||
RedisModuleString *r = RedisModule_GetBlockedClientPrivateData(ctx);
|
RedisModuleString *r = RedisModule_GetBlockedClientPrivateData(ctx);
|
||||||
return RedisModule_ReplyWithString(ctx, r);
|
return RedisModule_ReplyWithString(ctx, r);
|
||||||
} else if (RedisModule_IsBlockedTimeoutRequest(ctx)) {
|
} else if (RedisModule_IsBlockedTimeoutRequest(ctx)) {
|
||||||
|
RedisModule_UnblockClient(blocked_client, NULL); /* Must be called to avoid leaks. */
|
||||||
blocked_client = NULL;
|
blocked_client = NULL;
|
||||||
return RedisModule_ReplyWithSimpleString(ctx, "Timed out");
|
return RedisModule_ReplyWithSimpleString(ctx, "Timed out");
|
||||||
}
|
}
|
||||||
@ -245,7 +246,9 @@ int Release_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc
|
|||||||
return RedisModule_ReplyWithError(ctx, "ERR No blocked client");
|
return RedisModule_ReplyWithError(ctx, "ERR No blocked client");
|
||||||
}
|
}
|
||||||
|
|
||||||
RedisModule_UnblockClient(blocked_client, argv[1]);
|
RedisModuleString *replystr = argv[1];
|
||||||
|
RedisModule_RetainString(ctx, replystr);
|
||||||
|
int err = RedisModule_UnblockClient(blocked_client, replystr);
|
||||||
blocked_client = NULL;
|
blocked_client = NULL;
|
||||||
|
|
||||||
RedisModule_ReplyWithSimpleString(ctx, "OK");
|
RedisModule_ReplyWithSimpleString(ctx, "OK");
|
||||||
|
Loading…
Reference in New Issue
Block a user