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

Function resetCommand

src/networking.cpp:3008–3048  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

3006/* Reset the client state to resemble a newly connected client.
3007 */
3008void resetCommand(client *c) {
3009 listNode *ln;
3010
3011 /* MONITOR clients are also marked with CLIENT_SLAVE, we need to
3012 * distinguish between the two.
3013 */
3014 if (c->flags & CLIENT_MONITOR) {
3015 ln = listSearchKey(g_pserver->monitors,c);
3016 serverAssert(ln != NULL);
3017 listDelNode(g_pserver->monitors,ln);
3018
3019 c->flags &= ~(CLIENT_MONITOR|CLIENT_SLAVE);
3020 }
3021
3022 if (c->flags & (CLIENT_SLAVE|CLIENT_MASTER|CLIENT_MODULE)) {
3023 addReplyError(c,"can only reset normal client connections");
3024 return;
3025 }
3026
3027 if (c->flags & CLIENT_TRACKING) disableTracking(c);
3028 selectDb(c,0);
3029 c->resp = 2;
3030
3031 clientSetDefaultAuth(c);
3032 moduleNotifyUserChanged(c);
3033 discardTransaction(c);
3034
3035 pubsubUnsubscribeAllChannels(c,0);
3036 pubsubUnsubscribeAllPatterns(c,0);
3037
3038 if (c->name) {
3039 decrRefCount(c->name);
3040 c->name = NULL;
3041 }
3042
3043 /* Selectively clear state flags not covered above */
3044 c->flags &= ~(CLIENT_ASKING|CLIENT_READONLY|CLIENT_PUBSUB|
3045 CLIENT_REPLY_OFF|CLIENT_REPLY_SKIP_NEXT);
3046
3047 addReplyStatus(c,"RESET");
3048}
3049
3050void clientCommand(client *c) {
3051 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