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