diff options
author | Oran Agra <oran@redislabs.com> | 2019-11-04 08:50:29 +0200 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2019-11-04 08:50:29 +0200 |
commit | 04233097688ee35d451c6f5cd64c28e57ca81b53 (patch) | |
tree | 5082d820bb59819eb02307e099ee47c9106b6bfe /tests/modules/infotest.c | |
parent | deebed23e16c2cab9e0362e94bca8545d6e33596 (diff) | |
download | redis-04233097688ee35d451c6f5cd64c28e57ca81b53.tar.gz |
Add RM_ServerInfoGetFieldUnsigned
rename RM_ServerInfoGetFieldNumerical RM_ServerInfoGetFieldSigned
move string2ull to util.c
fix leak in RM_GetServerInfo when duplicate info fields exist
Diffstat (limited to 'tests/modules/infotest.c')
-rw-r--r-- | tests/modules/infotest.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/modules/infotest.c b/tests/modules/infotest.c index a21fefffc..4cb77ee87 100644 --- a/tests/modules/infotest.c +++ b/tests/modules/infotest.c @@ -5,6 +5,7 @@ void InfoFunc(RedisModuleInfoCtx *ctx, int for_crash_report) { RedisModule_InfoAddSection(ctx, ""); RedisModule_InfoAddFieldLongLong(ctx, "global", -2); + RedisModule_InfoAddFieldULongLong(ctx, "uglobal", (unsigned long long)-2); RedisModule_InfoAddSection(ctx, "Spanish"); RedisModule_InfoAddFieldCString(ctx, "uno", "one"); @@ -41,7 +42,11 @@ int info_get(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, char field field = RedisModule_StringPtrLen(argv[2], NULL); RedisModuleServerInfoData *info = RedisModule_GetServerInfo(ctx, section); if (field_type=='i') { - long long ll = RedisModule_ServerInfoGetFieldNumerical(info, field, &err); + long long ll = RedisModule_ServerInfoGetFieldSigned(info, field, &err); + if (err==REDISMODULE_OK) + RedisModule_ReplyWithLongLong(ctx, ll); + } else if (field_type=='u') { + unsigned long long ll = (unsigned long long)RedisModule_ServerInfoGetFieldUnsigned(info, field, &err); if (err==REDISMODULE_OK) RedisModule_ReplyWithLongLong(ctx, ll); } else if (field_type=='d') { @@ -78,6 +83,10 @@ int info_geti(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return info_get(ctx, argv, argc, 'i'); } +int info_getu(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { + return info_get(ctx, argv, argc, 'u'); +} + int info_getd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return info_get(ctx, argv, argc, 'd'); } @@ -96,6 +105,8 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) return REDISMODULE_ERR; if (RedisModule_CreateCommand(ctx,"info.geti", info_geti,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_CreateCommand(ctx,"info.getu", info_getu,"",0,0,0) == REDISMODULE_ERR) + return REDISMODULE_ERR; if (RedisModule_CreateCommand(ctx,"info.getd", info_getd,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; |