MCPcopy Create free account
hub / github.com/F-Stack/f-stack / resetCommand

Function resetCommand

app/redis-6.2.6/src/networking.c:2427–2467  ·  view source on GitHub ↗

Reset the client state to resemble a newly connected client. */

Source from the content-addressed store, hash-verified

2425/* Reset the client state to resemble a newly connected client.
2426 */
2427void resetCommand(client *c) {
2428 listNode *ln;
2429
2430 /* MONITOR clients are also marked with CLIENT_SLAVE, we need to
2431 * distinguish between the two.
2432 */
2433 if (c->flags & CLIENT_MONITOR) {
2434 ln = listSearchKey(server.monitors,c);
2435 serverAssert(ln != NULL);
2436 listDelNode(server.monitors,ln);
2437
2438 c->flags &= ~(CLIENT_MONITOR|CLIENT_SLAVE);
2439 }
2440
2441 if (c->flags & (CLIENT_SLAVE|CLIENT_MASTER|CLIENT_MODULE)) {
2442 addReplyError(c,"can only reset normal client connections");
2443 return;
2444 }
2445
2446 if (c->flags & CLIENT_TRACKING) disableTracking(c);
2447 selectDb(c,0);
2448 c->resp = 2;
2449
2450 clientSetDefaultAuth(c);
2451 moduleNotifyUserChanged(c);
2452 discardTransaction(c);
2453
2454 pubsubUnsubscribeAllChannels(c,0);
2455 pubsubUnsubscribeAllPatterns(c,0);
2456
2457 if (c->name) {
2458 decrRefCount(c->name);
2459 c->name = NULL;
2460 }
2461
2462 /* Selectively clear state flags not covered above */
2463 c->flags &= ~(CLIENT_ASKING|CLIENT_READONLY|CLIENT_PUBSUB|
2464 CLIENT_REPLY_OFF|CLIENT_REPLY_SKIP_NEXT);
2465
2466 addReplyStatus(c,"RESET");
2467}
2468
2469void clientCommand(client *c) {
2470 listNode *ln;

Callers

nothing calls this directly

Calls 12

listSearchKeyFunction · 0.85
listDelNodeFunction · 0.85
addReplyErrorFunction · 0.85
disableTrackingFunction · 0.85
selectDbFunction · 0.85
clientSetDefaultAuthFunction · 0.85
moduleNotifyUserChangedFunction · 0.85
discardTransactionFunction · 0.85
decrRefCountFunction · 0.85
addReplyStatusFunction · 0.85

Tested by

no test coverage detected