summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorYossi Gottlieb <yossigo@gmail.com>2021-09-23 15:00:37 +0300
committerGitHub <noreply@github.com>2021-09-23 15:00:37 +0300
commitbebc7f8470a5c6093514abf02f2514268c78b28f (patch)
treeec3b0c86b57db47c94270b9bc7f9bf60395ea623 /tests/modules
parent2753429c99425e3d0216cba79e0e61192975f252 (diff)
downloadredis-bebc7f8470a5c6093514abf02f2514268c78b28f.tar.gz
Add RM_TrimStringAllocation(). (#9540)
This commit makes it possible to explicitly trim the allocation of a RedisModuleString. Currently, Redis automatically trims strings that have been retained by a module command when it returns. However, this is not thread safe and may result with corruption in threaded modules. Supporting explicit trimming offers a backwards compatible workaround to this problem.
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/basics.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/modules/basics.c b/tests/modules/basics.c
index aa883cf10..e1d2c2115 100644
--- a/tests/modules/basics.c
+++ b/tests/modules/basics.c
@@ -401,6 +401,7 @@ int TestStringAppendAM(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
RedisModule_AutoMemory(ctx);
RedisModuleString *s = RedisModule_CreateString(ctx,"foo",3);
RedisModule_RetainString(ctx,s);
+ RedisModule_TrimStringAllocation(s); /* Mostly NOP, but exercises the API function */
RedisModule_StringAppendBuffer(ctx,s,"bar",3);
RedisModule_ReplyWithString(ctx,s);
RedisModule_FreeString(ctx,s);