diff options
author | antirez <antirez@gmail.com> | 2016-10-13 16:57:40 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-10-13 16:57:40 +0200 |
commit | 95c17c0cb24ebfff814b0c10e21d1a12b02fb478 (patch) | |
tree | 05e606f171b9f21c71e6ffdb2cec3cdfdb2dd151 /src/module.c | |
parent | 58601c8f7d6c279fe67a95950787775f11aec393 (diff) | |
download | redis-95c17c0cb24ebfff814b0c10e21d1a12b02fb478.tar.gz |
Modules: AbortBlock() API implemented.
Diffstat (limited to 'src/module.c')
-rw-r--r-- | src/module.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/module.c b/src/module.c index 91cd53090..66c09a426 100644 --- a/src/module.c +++ b/src/module.c @@ -3140,6 +3140,13 @@ int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) { return REDISMODULE_OK; } +/* Abort a blocked client blocking operation: the client will be unblocked + * without firing the reply callback. */ +int RM_AbortBlock(RedisModuleBlockedClient *bc) { + bc->reply_callback = NULL; + return RM_UnblockClient(bc,NULL); +} + /* This function will check the moduleUnblockedClients queue in order to * call the reply callback and really unblock the client. * @@ -3163,7 +3170,7 @@ void moduleHandleBlockedClients(void) { /* Release the lock during the loop, as long as we don't * touch the shared list. */ - if (c != NULL) { + if (c != NULL && bc->reply_callback != NULL) { RedisModuleCtx ctx = REDISMODULE_CTX_INIT; ctx.flags |= REDISMODULE_CTX_BLOCKED_REPLY; ctx.blocked_privdata = bc->privdata; @@ -3545,5 +3552,6 @@ void moduleRegisterCoreAPI(void) { REGISTER_API(IsBlockedReplyRequest); REGISTER_API(IsBlockedTimeoutRequest); REGISTER_API(GetBlockedClientPrivateData); + REGISTER_API(AbortBlock); REGISTER_API(Milliseconds); } |