MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / moduleTryServeClientBlockedOnKey

Function moduleTryServeClientBlockedOnKey

src/module.cpp:5444–5464  ·  view source on GitHub ↗

This function is called from module.c in order to check if a module * blocked for BLOCKED_MODULE and subtype 'on keys' (bc->blocked_on_keys true) * can really be unblocked, since the module was able to serve the client. * If the callback returns REDISMODULE_OK, then the client can be unblocked, * otherwise the client remains blocked and we'll retry again when one of * the keys it blocked for

Source from the content-addressed store, hash-verified

5442 * the keys it blocked for becomes "ready" again.
5443 * This function returns 1 if client was served (and should be unblocked) */
5444int moduleTryServeClientBlockedOnKey(client *c, robj *key) {
5445 int served = 0;
5446 RedisModuleBlockedClient *bc = (RedisModuleBlockedClient*)c->bpop.module_blocked_handle;
5447
5448 /* Protect against re-processing: don't serve clients that are already
5449 * in the unblocking list for any reason (including RM_UnblockClient()
5450 * explicit call). See #6798. */
5451 if (bc->unblocked) return 0;
5452
5453 RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
5454 ctx.flags |= REDISMODULE_CTX_BLOCKED_REPLY;
5455 ctx.blocked_ready_key = key;
5456 ctx.blocked_privdata = bc->privdata;
5457 ctx.module = bc->module;
5458 ctx.client = bc->client;
5459 ctx.blocked_client = bc;
5460 if (bc->reply_callback(&ctx,(void**)c->argv,c->argc) == REDISMODULE_OK)
5461 served = 1;
5462 moduleFreeContext(&ctx);
5463 return served;
5464}
5465
5466/* Block a client in the context of a blocking command, returning an handle
5467 * which will be used, later, in order to unblock the client with a call to

Callers 1

Calls 1

moduleFreeContextFunction · 0.85

Tested by

no test coverage detected