Reset the client state to resemble a newly connected client. */
| 2425 | /* Reset the client state to resemble a newly connected client. |
| 2426 | */ |
| 2427 | void 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 | |
| 2469 | void clientCommand(client *c) { |
| 2470 | listNode *ln; |
nothing calls this directly
no test coverage detected