Reset the client state to resemble a newly connected client. */
| 3006 | /* Reset the client state to resemble a newly connected client. |
| 3007 | */ |
| 3008 | void 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 | |
| 3050 | void clientCommand(client *c) { |
| 3051 | listNode *ln; |
nothing calls this directly
no test coverage detected