Unblock a client calling the right function depending on the kind * of operation the client is blocking for. */
| 190 | /* Unblock a client calling the right function depending on the kind |
| 191 | * of operation the client is blocking for. */ |
| 192 | void unblockClient(client *c) { |
| 193 | serverAssert(GlobalLocksAcquired()); |
| 194 | serverAssert(c->lock.fOwnLock()); |
| 195 | if (c->btype == BLOCKED_LIST || |
| 196 | c->btype == BLOCKED_ZSET || |
| 197 | c->btype == BLOCKED_STREAM) { |
| 198 | unblockClientWaitingData(c); |
| 199 | } else if (c->btype == BLOCKED_WAIT) { |
| 200 | unblockClientWaitingReplicas(c); |
| 201 | } else if (c->btype == BLOCKED_MODULE) { |
| 202 | if (moduleClientIsBlockedOnKeys(c)) unblockClientWaitingData(c); |
| 203 | unblockClientFromModule(c); |
| 204 | } else if (c->btype == BLOCKED_ASYNC) { |
| 205 | serverAssert(c->casyncOpsPending > 0); |
| 206 | c->casyncOpsPending--; |
| 207 | } else if (c->btype == BLOCKED_PAUSE) { |
| 208 | listDelNode(g_pserver->paused_clients,c->paused_list_node); |
| 209 | c->paused_list_node = NULL; |
| 210 | } else { |
| 211 | serverPanic("Unknown btype in unblockClient()."); |
| 212 | } |
| 213 | |
| 214 | /* Reset the client for a new query since, for blocking commands |
| 215 | * we do not do it immediately after the command returns (when the |
| 216 | * client got blocked) in order to be still able to access the argument |
| 217 | * vector from module callbacks and updateStatsOnUnblock. */ |
| 218 | if (c->btype != BLOCKED_PAUSE) { |
| 219 | freeClientOriginalArgv(c); |
| 220 | resetClient(c); |
| 221 | } |
| 222 | |
| 223 | /* Clear the flags, and put the client in the unblocked list so that |
| 224 | * we'll process new commands in its query buffer ASAP. */ |
| 225 | g_pserver->blocked_clients--; |
| 226 | g_pserver->blocked_clients_by_type[c->btype]--; |
| 227 | c->flags &= ~CLIENT_BLOCKED; |
| 228 | c->btype = BLOCKED_NONE; |
| 229 | removeClientFromTimeoutTable(c); |
| 230 | queueClientForReprocessing(c); |
| 231 | } |
| 232 | |
| 233 | /* This function gets called when a blocked client timed out in order to |
| 234 | * send it a reply of some kind. After this function is called, |
no test coverage detected