Unverified Commit 4bd77483 authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
Browse files

Tests: fix commandfilter crash on alpine. (#9307)

Loading and unloading the shared object does not initialize global vars
on alpine.
parent cf61ad14
...@@ -11,8 +11,8 @@ static const char retained_command_name[] = "commandfilter.retained"; ...@@ -11,8 +11,8 @@ static const char retained_command_name[] = "commandfilter.retained";
static const char unregister_command_name[] = "commandfilter.unregister"; static const char unregister_command_name[] = "commandfilter.unregister";
static int in_log_command = 0; static int in_log_command = 0;
static RedisModuleCommandFilter *filter = NULL; static RedisModuleCommandFilter *filter;
static RedisModuleString *retained = NULL; static RedisModuleString *retained;
int CommandFilter_UnregisterCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) int CommandFilter_UnregisterCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
{ {
...@@ -149,6 +149,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) ...@@ -149,6 +149,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
long long noself = 0; long long noself = 0;
log_key_name = RedisModule_CreateStringFromString(ctx, argv[0]); log_key_name = RedisModule_CreateStringFromString(ctx, argv[0]);
RedisModule_StringToLongLong(argv[1], &noself); RedisModule_StringToLongLong(argv[1], &noself);
retained = NULL;
if (RedisModule_CreateCommand(ctx,log_command_name, if (RedisModule_CreateCommand(ctx,log_command_name,
CommandFilter_LogCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) CommandFilter_LogCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR)
...@@ -176,5 +177,6 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) ...@@ -176,5 +177,6 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
int RedisModule_OnUnload(RedisModuleCtx *ctx) { int RedisModule_OnUnload(RedisModuleCtx *ctx) {
RedisModule_FreeString(ctx, log_key_name); RedisModule_FreeString(ctx, log_key_name);
if (retained) RedisModule_FreeString(NULL, retained); if (retained) RedisModule_FreeString(NULL, retained);
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