MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / processCommandAndResetClient

Function processCommandAndResetClient

src/networking.cpp:2512–2534  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

2510 * The function returns C_ERR in case the client was freed as a side effect
2511 * of processing the command, otherwise C_OK is returned. */
2512int processCommandAndResetClient(client *c, int flags) {
2513 int deadclient = 0;
2514 client *old_client = serverTL->current_client;
2515 serverTL->current_client = c;
2516 serverAssert((flags & CMD_CALL_ASYNC) || GlobalLocksAcquired());
2517
2518 if (processCommand(c, flags) == C_OK) {
2519 commandProcessed(c, flags);
2520 }
2521 if (serverTL->current_client == NULL) deadclient = 1;
2522 /*
2523 * Restore the old client, this is needed because when a script
2524 * times out, we will get into this code from processEventsWhileBlocked.
2525 * Which will cause to set the server.current_client. If not restored
2526 * we will return 1 to our caller which will falsely indicate the client
2527 * is dead and will stop reading from its buffer.
2528 */
2529 serverTL->current_client = old_client;
2530 /* performEvictions may flush slave output buffers. This may
2531 * result in a replica, that may be the active client, to be
2532 * freed. */
2533 return deadclient ? C_ERR : C_OK;
2534}
2535
2536/* This function will execute any fully parsed commands pending on
2537 * the client. Returns C_ERR if the client is no longer valid after executing

Callers 2

processInputBufferFunction · 0.85

Calls 3

GlobalLocksAcquiredFunction · 0.85
processCommandFunction · 0.85
commandProcessedFunction · 0.85

Tested by

no test coverage detected