mirror of https://github.com/redis/redis.git
* fix test
* cleanup strval2 on if an error during the OnLoad was encountered.
This commit is contained in:
parent
294492dbf2
commit
f7353db7eb
|
@ -165,6 +165,17 @@ int registerBlockCheck(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
void cleanup(RedisModuleCtx *ctx) {
|
||||
if (strval) {
|
||||
RedisModule_FreeString(ctx, strval);
|
||||
strval = NULL;
|
||||
}
|
||||
if (strval2) {
|
||||
RedisModule_FreeString(ctx, strval2);
|
||||
strval2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
|
@ -264,22 +275,12 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||
|
||||
return REDISMODULE_OK;
|
||||
err:
|
||||
if (strval) {
|
||||
RedisModule_FreeString(ctx, strval);
|
||||
strval = NULL;
|
||||
}
|
||||
cleanup(ctx);
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
|
||||
int RedisModule_OnUnload(RedisModuleCtx *ctx) {
|
||||
REDISMODULE_NOT_USED(ctx);
|
||||
if (strval) {
|
||||
RedisModule_FreeString(ctx, strval);
|
||||
strval = NULL;
|
||||
}
|
||||
if (strval2) {
|
||||
RedisModule_FreeString(ctx, strval2);
|
||||
strval2 = NULL;
|
||||
}
|
||||
cleanup(ctx);
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ start_server {tags {"modules"}} {
|
|||
|
||||
# missing LoadConfigs call
|
||||
catch {exec src/redis-server --loadmodule "$testmodule" noload --moduleconfigs.string "hello"} err
|
||||
assert_match {*Module Configurations were not set, likely a missing LoadConfigs call. Unloading the module.*} $err
|
||||
assert_match {*Module Configurations were not set, missing LoadConfigs call. Unloading the module.*} $err
|
||||
|
||||
# successful
|
||||
start_server [list overrides [list loadmodule "$testmodule" moduleconfigs.string "bootedup" moduleconfigs.enum two moduleconfigs.flags "two four"]] {
|
||||
|
|
Loading…
Reference in New Issue