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

Function replicationCacheMasterUsingMaster

src/replication.cpp:4417–4431  ·  view source on GitHub ↗

This function is called when reloading master info from an RDB in Active Replica mode. * It creates a cached master client using the info contained in the redisMaster struct. * * Assumes that the passed struct contains valid master info. */

Source from the content-addressed store, hash-verified

4415 *
4416 * Assumes that the passed struct contains valid master info. */
4417void replicationCacheMasterUsingMaster(redisMaster *mi) {
4418 if (mi->cached_master) {
4419 freeClient(mi->cached_master);
4420 }
4421
4422 replicationCreateMasterClient(mi, NULL, -1);
4423 std::lock_guard<decltype(mi->master->lock)> lock(mi->master->lock);
4424
4425 memcpy(mi->master->replid, mi->master_replid, sizeof(mi->master_replid));
4426 mi->master->reploff = mi->master_initial_offset;
4427
4428 unlinkClient(mi->master);
4429 mi->cached_master = mi->master;
4430 mi->master = NULL;
4431}
4432
4433/* Free a cached master, called when there are no longer the conditions for
4434 * a partial resync on reconnection. */

Callers 1

Calls 3

unlinkClientFunction · 0.85
freeClientFunction · 0.70

Tested by

no test coverage detected