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

Function blockClient

src/blocked.cpp:90–110  ·  view source on GitHub ↗

Block a client for the specific operation type. Once the CLIENT_BLOCKED * flag is set client query buffer is not longer processed, but accumulated, * and will be processed when the client is unblocked. */

Source from the content-addressed store, hash-verified

88 * flag is set client query buffer is not longer processed, but accumulated,
89 * and will be processed when the client is unblocked. */
90void blockClient(client *c, int btype) {
91 serverAssert(GlobalLocksAcquired());
92 /* Master client should never be blocked unless pause or module */
93 serverAssert(!(c->flags & CLIENT_MASTER &&
94 btype != BLOCKED_MODULE &&
95 btype != BLOCKED_PAUSE));
96
97 c->flags |= CLIENT_BLOCKED;
98 c->btype = btype;
99 if (btype == BLOCKED_ASYNC)
100 c->casyncOpsPending++;
101 g_pserver->blocked_clients++;
102 g_pserver->blocked_clients_by_type[btype]++;
103 addClientToTimeoutTable(c);
104 if (btype == BLOCKED_PAUSE) {
105 listAddNodeTail(g_pserver->paused_clients, c);
106 c->paused_list_node = listLast(g_pserver->paused_clients);
107 /* Mark this client to execute its command */
108 c->flags |= CLIENT_PENDING_COMMAND;
109 }
110}
111
112/* This function is called after a client has finished a blocking operation
113 * in order to update the total command duration, log the command into

Callers 6

keysCommandFunction · 0.85
waitCommandFunction · 0.85
processCommandFunction · 0.85
asyncCommandMethod · 0.85
blockForKeysFunction · 0.85
moduleBlockClientFunction · 0.85

Calls 3

GlobalLocksAcquiredFunction · 0.85
addClientToTimeoutTableFunction · 0.85
listAddNodeTailFunction · 0.85

Tested by

no test coverage detected