mirror of https://github.com/valkey-io/valkey
Backport: Fix potential infinite loop in clusterNodeGetMaster (#2830)
Issue #609 is marked as completed (fixed by #651); however, the fix is only present in versions 8.0 and above. This PR backports the fix into the 7.2 branch Signed-off-by: hieu2102 <hieund2102@gmail.com>
This commit is contained in:
parent
97b6663c77
commit
4207301f1e
|
|
@ -7746,8 +7746,12 @@ unsigned int countKeysInSlot(unsigned int hashslot) {
|
|||
}
|
||||
|
||||
clusterNode *clusterNodeGetMaster(clusterNode *node) {
|
||||
while (node->slaveof != NULL) node = node->slaveof;
|
||||
return node;
|
||||
clusterNode *master = node;
|
||||
while (master->slaveof != NULL) {
|
||||
master = master->slaveof;
|
||||
if (master == node) break;
|
||||
}
|
||||
return master;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue