diff options
author | Shaya Potter <shaya@redislabs.com> | 2021-10-21 14:01:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 14:01:10 +0300 |
commit | cf860df59921efcc74be410bdf165abd784df502 (patch) | |
tree | 5a269de112623303c6c12f68ad72beb7efe047fb /tests/modules/blockedclient.c | |
parent | 8f745da1597efdb5f9275af91a63c08ba26abb61 (diff) | |
download | redis-cf860df59921efcc74be410bdf165abd784df502.tar.gz |
Fix module blocked clients RESP version (#9634)
Before this commit, module blocked clients did not carry through the original RESP version, resulting with RESP3 clients receiving unexpected RESP2 replies.
Diffstat (limited to 'tests/modules/blockedclient.c')
-rw-r--r-- | tests/modules/blockedclient.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/modules/blockedclient.c b/tests/modules/blockedclient.c index c3b0d5eb4..ebe89ecb2 100644 --- a/tests/modules/blockedclient.c +++ b/tests/modules/blockedclient.c @@ -188,6 +188,21 @@ int do_rm_call(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){ return REDISMODULE_OK; } +/* simulate a blocked client replying to a thread safe context without creating a thread */ +int do_fake_bg_true(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { + UNUSED(argv); + UNUSED(argc); + + RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx, NULL, NULL, NULL, 0); + RedisModuleCtx *bctx = RedisModule_GetThreadSafeContext(bc); + + RedisModule_ReplyWithBool(bctx, 1); + + RedisModule_FreeThreadSafeContext(bctx); + RedisModule_UnblockClient(bc, NULL); + + return REDISMODULE_OK; +} int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); @@ -205,5 +220,8 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) if (RedisModule_CreateCommand(ctx, "do_bg_rm_call", do_bg_rm_call, "", 0, 0, 0) == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_CreateCommand(ctx, "do_fake_bg_true", do_fake_bg_true, "", 0, 0, 0) == REDISMODULE_ERR) + return REDISMODULE_ERR; + return REDISMODULE_OK; } |