Fix regression in active replication caused by multimaster PR

Former-commit-id: 283998404fb69c8b3f6263b8ef7813bf3e99e608
This commit is contained in:
John Sully 2019-04-04 16:50:40 -04:00
parent bd6b3f17e5
commit fdbc361e58

View File

@ -75,14 +75,8 @@ char *replicationGetSlaveName(client *c) {
return buf; return buf;
} }
static bool FSameHost(client *clientA, client *clientB) static bool FSameUuidNoNil(const unsigned char *a, const unsigned char *b)
{ {
if (clientA == nullptr || clientB == nullptr)
return false;
const unsigned char *a = clientA->uuid;
const unsigned char *b = clientB->uuid;
unsigned char zeroCheck = 0; unsigned char zeroCheck = 0;
for (int i = 0; i < UUID_BINARY_LEN; ++i) for (int i = 0; i < UUID_BINARY_LEN; ++i)
{ {
@ -93,6 +87,17 @@ static bool FSameHost(client *clientA, client *clientB)
return (zeroCheck != 0); // if the UUID is nil then it is never equal return (zeroCheck != 0); // if the UUID is nil then it is never equal
} }
static bool FSameHost(client *clientA, client *clientB)
{
if (clientA == nullptr || clientB == nullptr)
return false;
const unsigned char *a = clientA->uuid;
const unsigned char *b = clientB->uuid;
return FSameUuidNoNil(a, b);
}
static bool FMasterHost(client *c) static bool FMasterHost(client *c)
{ {
listIter li; listIter li;
@ -101,7 +106,7 @@ static bool FMasterHost(client *c)
while ((ln = listNext(&li))) while ((ln = listNext(&li)))
{ {
redisMaster *mi = (redisMaster*)listNodeValue(ln); redisMaster *mi = (redisMaster*)listNodeValue(ln);
if (FSameHost(mi->master, c)) if (FSameUuidNoNil(mi->master_uuid, c->uuid))
return true; return true;
} }
return false; return false;