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