Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check in CLUSTERLINK KILL cmd to avoid freeing links to myself #689

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ clusterLink *createClusterLink(clusterNode *node) {
* This function will just make sure that the original node associated
* with this link will have the 'link' field set to NULL. */
void freeClusterLink(clusterLink *link) {
serverAssert(link != NULL);
if (link->conn) {
connClose(link->conn);
link->conn = NULL;
Expand Down Expand Up @@ -5815,6 +5816,10 @@ int handleDebugClusterCommand(client *c) {
addReplyErrorFormat(c, "Unknown node %s", (char *)c->argv[4]->ptr);
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. */
if (!strcasecmp(c->argv[3]->ptr, "from")) {
Expand Down
Loading