This function is called every time, in the client structure 'c', there is * more query buffer to process, because we read more data from the socket * or because a client was blocked and later reactivated, so there could be * pending query buffer, already representing a full command, to process. */
| 2635 | * or because a client was blocked and later reactivated, so there could be |
| 2636 | * pending query buffer, already representing a full command, to process. */ |
| 2637 | void processInputBuffer(client *c, bool fParse, int callFlags) { |
| 2638 | AssertCorrectThread(c); |
| 2639 | |
| 2640 | if (fParse) |
| 2641 | parseClientCommandBuffer(c); |
| 2642 | |
| 2643 | /* Keep processing while there is something in the input buffer */ |
| 2644 | while (!c->vecqueuedcmd.empty()) { |
| 2645 | /* Return if we're still parsing this command */ |
| 2646 | auto &cmd = c->vecqueuedcmd.front(); |
| 2647 | if (cmd.argc != cmd.argcMax) break; |
| 2648 | if (c->flags & CLIENT_EXECUTING_COMMAND) break; |
| 2649 | |
| 2650 | if (!FClientReady(c)) break; |
| 2651 | |
| 2652 | if ((callFlags & CMD_CALL_ASYNC) && !FAsyncCommand(cmd)) |
| 2653 | break; |
| 2654 | |
| 2655 | zfree(c->argv); |
| 2656 | c->argc = cmd.argc; |
| 2657 | c->argv = cmd.argv; |
| 2658 | cmd.argv = nullptr; |
| 2659 | c->argv_len_sumActive = cmd.argv_len_sum; |
| 2660 | cmd.argv_len_sum = 0; |
| 2661 | c->reploff_cmd = cmd.reploff; |
| 2662 | serverAssert(c->argv != nullptr); |
| 2663 | |
| 2664 | c->vecqueuedcmd.erase(c->vecqueuedcmd.begin()); |
| 2665 | |
| 2666 | /* Multibulk processing could see a <= 0 length. */ |
| 2667 | if (c->argc == 0) { |
| 2668 | resetClient(c); |
| 2669 | } else { |
| 2670 | c->flags |= CLIENT_EXECUTING_COMMAND; |
| 2671 | /* We are finally ready to execute the command. */ |
| 2672 | if (processCommandAndResetClient(c, callFlags) == C_ERR) { |
| 2673 | /* If the client is no longer valid, we avoid exiting this |
| 2674 | * loop and trimming the client buffer later. So we return |
| 2675 | * ASAP in that case. */ |
| 2676 | c->flags &= ~CLIENT_EXECUTING_COMMAND; |
| 2677 | return; |
| 2678 | } |
| 2679 | c->flags &= ~CLIENT_EXECUTING_COMMAND; |
| 2680 | } |
| 2681 | } |
| 2682 | } |
| 2683 | |
| 2684 | void readQueryFromClient(connection *conn) { |
| 2685 | client *c = (client*)connGetPrivateData(conn); |
no test coverage detected