mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
* fix test
* cleanup strval2 on if an error during the OnLoad was encountered.
This commit is contained in:
committed by
YaacovHazan
parent
294492dbf2
commit
f7353db7eb
@@ -165,6 +165,17 @@ int registerBlockCheck(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||||||
return REDISMODULE_OK;
|
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) {
|
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||||
REDISMODULE_NOT_USED(argv);
|
REDISMODULE_NOT_USED(argv);
|
||||||
REDISMODULE_NOT_USED(argc);
|
REDISMODULE_NOT_USED(argc);
|
||||||
@@ -264,22 +275,12 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||||||
|
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
err:
|
err:
|
||||||
if (strval) {
|
cleanup(ctx);
|
||||||
RedisModule_FreeString(ctx, strval);
|
|
||||||
strval = NULL;
|
|
||||||
}
|
|
||||||
return REDISMODULE_ERR;
|
return REDISMODULE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RedisModule_OnUnload(RedisModuleCtx *ctx) {
|
int RedisModule_OnUnload(RedisModuleCtx *ctx) {
|
||||||
REDISMODULE_NOT_USED(ctx);
|
REDISMODULE_NOT_USED(ctx);
|
||||||
if (strval) {
|
cleanup(ctx);
|
||||||
RedisModule_FreeString(ctx, strval);
|
|
||||||
strval = NULL;
|
|
||||||
}
|
|
||||||
if (strval2) {
|
|
||||||
RedisModule_FreeString(ctx, strval2);
|
|
||||||
strval2 = NULL;
|
|
||||||
}
|
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ start_server {tags {"modules"}} {
|
|||||||
|
|
||||||
# missing LoadConfigs call
|
# missing LoadConfigs call
|
||||||
catch {exec src/redis-server --loadmodule "$testmodule" noload --moduleconfigs.string "hello"} err
|
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
|
# successful
|
||||||
start_server [list overrides [list loadmodule "$testmodule" moduleconfigs.string "bootedup" moduleconfigs.enum two moduleconfigs.flags "two four"]] {
|
start_server [list overrides [list loadmodule "$testmodule" moduleconfigs.string "bootedup" moduleconfigs.enum two moduleconfigs.flags "two four"]] {
|
||||||
|
|||||||
Reference in New Issue
Block a user