MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelDropConnections

Function sentinelDropConnections

src/sentinel.cpp:1171–1196  ·  view source on GitHub ↗

Drop all connections to other sentinels. Returns the number of connections * dropped.*/

Source from the content-addressed store, hash-verified

1169/* Drop all connections to other sentinels. Returns the number of connections
1170 * dropped.*/
1171int sentinelDropConnections(void) {
1172 dictIterator *di;
1173 dictEntry *de;
1174 int dropped = 0;
1175
1176 di = dictGetIterator(sentinel.masters);
1177 while ((de = dictNext(di)) != NULL) {
1178 dictIterator *sdi;
1179 dictEntry *sde;
1180
1181 sentinelRedisInstance *ri = (sentinelRedisInstance*)dictGetVal(de);
1182 sdi = dictGetIterator(ri->sentinels);
1183 while ((sde = dictNext(sdi)) != NULL) {
1184 sentinelRedisInstance *si = (sentinelRedisInstance*)dictGetVal(sde);
1185 if (!si->link->disconnected) {
1186 instanceLinkCloseConnection(si->link, si->link->pc);
1187 instanceLinkCloseConnection(si->link, si->link->cc);
1188 dropped++;
1189 }
1190 }
1191 dictReleaseIterator(sdi);
1192 }
1193 dictReleaseIterator(di);
1194
1195 return dropped;
1196}
1197
1198/* When we detect a Sentinel to switch address (reporting a different IP/port
1199 * pair in Hello messages), let's update all the matching Sentinels in the

Callers 1

sentinelConfigSetCommandFunction · 0.85

Calls 4

dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected