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. */
| 88 | * flag is set client query buffer is not longer processed, but accumulated, |
| 89 | * and will be processed when the client is unblocked. */ |
| 90 | void 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 |
no test coverage detected