Add check in CLUSTERLINK KILL cmd to avoid freeing links to myself (#689)
Add check in CLUSTERLINK KILL cmd to avoid freeing cluster bus links to myself. Also add an assert in `freeClusterLink()`. Testing: ``` 127.0.0.1:6379> debug clusterlink kill all c0404ee68574c6aa1048aaebfe90283afe51d2fc (error) ERR Cannot free cluster link(s) to myself ``` Signed-off-by: Pierre Turin <pieturin@amazon.com>
This commit is contained in:
parent
b49eaad367
commit
495c35d918
@ -1185,6 +1185,7 @@ clusterLink *createClusterLink(clusterNode *node) {
|
|||||||
* This function will just make sure that the original node associated
|
* This function will just make sure that the original node associated
|
||||||
* with this link will have the 'link' field set to NULL. */
|
* with this link will have the 'link' field set to NULL. */
|
||||||
void freeClusterLink(clusterLink *link) {
|
void freeClusterLink(clusterLink *link) {
|
||||||
|
serverAssert(link != NULL);
|
||||||
if (link->conn) {
|
if (link->conn) {
|
||||||
connClose(link->conn);
|
connClose(link->conn);
|
||||||
link->conn = NULL;
|
link->conn = NULL;
|
||||||
@ -5815,6 +5816,10 @@ int handleDebugClusterCommand(client *c) {
|
|||||||
addReplyErrorFormat(c, "Unknown node %s", (char *)c->argv[4]->ptr);
|
addReplyErrorFormat(c, "Unknown node %s", (char *)c->argv[4]->ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (n == server.cluster->myself) {
|
||||||
|
addReplyErrorFormat(c, "Cannot free cluster link(s) to myself");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Terminate the link based on the direction or all. */
|
/* Terminate the link based on the direction or all. */
|
||||||
if (!strcasecmp(c->argv[3]->ptr, "from")) {
|
if (!strcasecmp(c->argv[3]->ptr, "from")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user