diff options
author | sundb <sundbcn@gmail.com> | 2021-09-14 20:14:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 15:14:09 +0300 |
commit | 1376d83363cf0e9c9f872762854518b16d8cedef (patch) | |
tree | 314b71edc9d8af73f195e2425b0a1e6b664557bb /tests/modules/blockonbackground.c | |
parent | f041990f2acde5ae1ef67351c6a505f3ef6fcf52 (diff) | |
download | redis-1376d83363cf0e9c9f872762854518b16d8cedef.tar.gz |
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.
Diffstat (limited to 'tests/modules/blockonbackground.c')
-rw-r--r-- | tests/modules/blockonbackground.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/modules/blockonbackground.c b/tests/modules/blockonbackground.c index 92f5876d2..ced77862d 100644 --- a/tests/modules/blockonbackground.c +++ b/tests/modules/blockonbackground.c @@ -31,6 +31,11 @@ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *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 * of the command BLOCK.DEBUG. */ void *BlockDebug_ThreadMain(void *arg) { @@ -225,7 +230,7 @@ int Block_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) * callback and differentiate the different code flows above. */ 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; } |