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
| 1454 | * The function returns 1 if the matching Sentinel was removed, otherwise |
| 1455 | * 0 if there was no Sentinel with this ID. */ |
| 1456 | int 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 |
no test coverage detected