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
| 5333 | * the keys it blocked for becomes "ready" again. |
| 5334 | * This function returns 1 if client was served (and should be unblocked) */ |
| 5335 | int moduleTryServeClientBlockedOnKey(client *c, robj *key) { |
| 5336 | int served = 0; |
| 5337 | RedisModuleBlockedClient *bc = c->bpop.module_blocked_handle; |
| 5338 | |
| 5339 | /* Protect against re-processing: don't serve clients that are already |
| 5340 | * in the unblocking list for any reason (including RM_UnblockClient() |
| 5341 | * explicit call). See #6798. */ |
| 5342 | if (bc->unblocked) return 0; |
| 5343 | |
| 5344 | RedisModuleCtx ctx = REDISMODULE_CTX_INIT; |
| 5345 | ctx.flags |= REDISMODULE_CTX_BLOCKED_REPLY; |
| 5346 | ctx.blocked_ready_key = key; |
| 5347 | ctx.blocked_privdata = bc->privdata; |
| 5348 | ctx.module = bc->module; |
| 5349 | ctx.client = bc->client; |
| 5350 | ctx.blocked_client = bc; |
| 5351 | if (bc->reply_callback(&ctx,(void**)c->argv,c->argc) == REDISMODULE_OK) |
| 5352 | served = 1; |
| 5353 | moduleFreeContext(&ctx); |
| 5354 | return served; |
| 5355 | } |
| 5356 | |
| 5357 | /* Block a client in the context of a blocking command, returning an handle |
| 5358 | * which will be used, later, in order to unblock the client with a call to |
no test coverage detected