Unverified Commit 1376d833 authored by sundb's avatar sundb Committed by GitHub
Browse files

Fix memory leak due to missing freeCallback in blockonbackground moduleapi test (#9499)

Before #9497, before redis-server was shut down, we did not manually shut down all the clients,
which would have prevented valgrind from detecting a memory leak in the client's argc.
parent f041990f
...@@ -31,6 +31,11 @@ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { ...@@ -31,6 +31,11 @@ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) {
RedisModule_Free(privdata); RedisModule_Free(privdata);
} }
/* Private data freeing callback for BLOCK.BLOCK command. */
void HelloBlock_FreeStringData(RedisModuleCtx *ctx, void *privdata) {
RedisModule_FreeString(ctx, (RedisModuleString*)privdata);
}
/* The thread entry point that actually executes the blocking part /* The thread entry point that actually executes the blocking part
* of the command BLOCK.DEBUG. */ * of the command BLOCK.DEBUG. */
void *BlockDebug_ThreadMain(void *arg) { void *BlockDebug_ThreadMain(void *arg) {
...@@ -225,7 +230,7 @@ int Block_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) ...@@ -225,7 +230,7 @@ int Block_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
* callback and differentiate the different code flows above. * callback and differentiate the different code flows above.
*/ */
blocked_client = RedisModule_BlockClient(ctx, Block_RedisCommand, blocked_client = RedisModule_BlockClient(ctx, Block_RedisCommand,
timeout > 0 ? Block_RedisCommand : NULL, NULL, timeout); timeout > 0 ? Block_RedisCommand : NULL, HelloBlock_FreeStringData, timeout);
return REDISMODULE_OK; return REDISMODULE_OK;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment