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. */
| 4415 | * |
| 4416 | * Assumes that the passed struct contains valid master info. */ |
| 4417 | void 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. */ |
no test coverage detected