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

Function sentinelLeaderIncr

src/sentinel.cpp:4424–4438  ·  view source on GitHub ↗

Helper function for sentinelGetLeader, increment the counter * relative to the specified runid. */

Source from the content-addressed store, hash-verified

4422/* Helper function for sentinelGetLeader, increment the counter
4423 * relative to the specified runid. */
4424int sentinelLeaderIncr(dict *counters, char *runid) {
4425 dictEntry *existing, *de;
4426 uint64_t oldval;
4427
4428 de = dictAddRaw(counters,runid,&existing);
4429 if (existing) {
4430 oldval = dictGetUnsignedIntegerVal(existing);
4431 dictSetUnsignedIntegerVal(existing,oldval+1);
4432 return oldval+1;
4433 } else {
4434 serverAssert(de != NULL);
4435 dictSetUnsignedIntegerVal(de,1);
4436 return 1;
4437 }
4438}
4439
4440/* Scan all the Sentinels attached to this master to check if there
4441 * is a leader for the specified epoch.

Callers 1

sentinelGetLeaderFunction · 0.85

Calls 1

dictAddRawFunction · 0.85

Tested by

no test coverage detected