MCPcopy Create free account
hub / github.com/F-Stack/f-stack / removeMatchingSentinelFromMaster

Function removeMatchingSentinelFromMaster

app/redis-6.2.6/src/sentinel.c:1456–1474  ·  view source on GitHub ↗

This function remove the Sentinel with the specified ID from the * specified master. * * If "runid" is NULL the function returns ASAP. * * This function is useful because on Sentinels address switch, we want to * remove our old entry and add a new one for the same ID but with the new * address. * * The function returns 1 if the matching Sentinel was removed, otherwise * 0 if there was no

Source from the content-addressed store, hash-verified

1454 * The function returns 1 if the matching Sentinel was removed, otherwise
1455 * 0 if there was no Sentinel with this ID. */
1456int removeMatchingSentinelFromMaster(sentinelRedisInstance *master, char *runid) {
1457 dictIterator *di;
1458 dictEntry *de;
1459 int removed = 0;
1460
1461 if (runid == NULL) return 0;
1462
1463 di = dictGetSafeIterator(master->sentinels);
1464 while((de = dictNext(di)) != NULL) {
1465 sentinelRedisInstance *ri = dictGetVal(de);
1466
1467 if (ri->runid && strcmp(ri->runid,runid) == 0) {
1468 dictDelete(master->sentinels,ri->name);
1469 removed++;
1470 }
1471 }
1472 dictReleaseIterator(di);
1473 return removed;
1474}
1475
1476/* Search an instance with the same runid, ip and port into a dictionary
1477 * of instances. Return NULL if not found, otherwise return the instance

Callers 1

Calls 5

dictGetSafeIteratorFunction · 0.85
strcmpFunction · 0.85
dictNextFunction · 0.70
dictDeleteFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected