Modules: Fix blocked-client-related memory leak

If a blocked module client times-out (or disconnects, unblocked
by CLIENT command, etc.) we need to call moduleUnblockClient
in order to free memory allocated by the module sub-system
and blocked-client private data

Other changes:
Made blockedonkeys.tcl tests a bit more aggressive in order
to smoke-out potential memory leaks
This commit is contained in:
Guy Benoish
2019-12-24 17:14:23 +05:30
parent 324e22accf
commit d7d13721d3
3 changed files with 51 additions and 6 deletions

View File

@ -4271,6 +4271,15 @@ void unblockClientFromModule(client *c) {
moduleFreeContext(&ctx);
}
/* If we made it here and client is still blocked it means that the command
* timed-out, client was killed or disconnected and disconnect_callback was
* not implemented (or it was, but RM_UnblockClient was not called from
* within it, as it should).
* We must call moduleUnblockClient in order to free privdata and
* RedisModuleBlockedClient */
if (!bc->unblocked)
moduleUnblockClient(c);
bc->client = NULL;
/* Reset the client for a new query since, for blocking commands implemented
* into modules, we do not it immediately after the command returns (and