This function calls processCommand(), but also performs a few sub tasks * for the client that are useful in that context: * * 1. It sets the current client to the client 'c'. * 2. calls commandProcessed() if the command was handled. * * The function returns C_ERR in case the client was freed as a side effect * of processing the command, otherwise C_OK is returned. */
| 2033 | * The function returns C_ERR in case the client was freed as a side effect |
| 2034 | * of processing the command, otherwise C_OK is returned. */ |
| 2035 | int processCommandAndResetClient(client *c) { |
| 2036 | int deadclient = 0; |
| 2037 | client *old_client = server.current_client; |
| 2038 | server.current_client = c; |
| 2039 | if (processCommand(c) == C_OK) { |
| 2040 | commandProcessed(c); |
| 2041 | } |
| 2042 | if (server.current_client == NULL) deadclient = 1; |
| 2043 | /* |
| 2044 | * Restore the old client, this is needed because when a script |
| 2045 | * times out, we will get into this code from processEventsWhileBlocked. |
| 2046 | * Which will cause to set the server.current_client. If not restored |
| 2047 | * we will return 1 to our caller which will falsely indicate the client |
| 2048 | * is dead and will stop reading from its buffer. |
| 2049 | */ |
| 2050 | server.current_client = old_client; |
| 2051 | /* performEvictions may flush slave output buffers. This may |
| 2052 | * result in a slave, that may be the active client, to be |
| 2053 | * freed. */ |
| 2054 | return deadclient ? C_ERR : C_OK; |
| 2055 | } |
| 2056 | |
| 2057 | |
| 2058 | /* This function will execute any fully parsed commands pending on |
no test coverage detected