MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cancelReplicationHandshake

Function cancelReplicationHandshake

app/redis-6.2.6/src/replication.c:2587–2610  ·  view source on GitHub ↗

This function aborts a non blocking replication attempt if there is one * in progress, by canceling the non-blocking connect attempt or * the initial bulk transfer. * * If there was a replication handshake in progress 1 is returned and * the replication state (server.repl_state) set to REPL_STATE_CONNECT. * * Otherwise zero is returned and no operation is performed at all. */

Source from the content-addressed store, hash-verified

2585 *
2586 * Otherwise zero is returned and no operation is performed at all. */
2587int cancelReplicationHandshake(int reconnect) {
2588 if (server.repl_state == REPL_STATE_TRANSFER) {
2589 replicationAbortSyncTransfer();
2590 server.repl_state = REPL_STATE_CONNECT;
2591 } else if (server.repl_state == REPL_STATE_CONNECTING ||
2592 slaveIsInHandshakeState())
2593 {
2594 undoConnectWithMaster();
2595 server.repl_state = REPL_STATE_CONNECT;
2596 } else {
2597 return 0;
2598 }
2599
2600 if (!reconnect)
2601 return 1;
2602
2603 /* try to re-connect without waiting for replicationCron, this is needed
2604 * for the "diskless loading short read" test. */
2605 serverLog(LL_NOTICE,"Reconnecting to MASTER %s:%d after failure",
2606 server.masterhost, server.masterport);
2607 connectWithMaster();
2608
2609 return 1;
2610}
2611
2612/* Set replication to the specified master address and port. */
2613void replicationSetMaster(char *ip, int port) {

Callers 4

readSyncBulkPayloadFunction · 0.85
replicationSetMasterFunction · 0.85
replicationUnsetMasterFunction · 0.85
replicationCronFunction · 0.85

Calls 4

slaveIsInHandshakeStateFunction · 0.85
undoConnectWithMasterFunction · 0.85
connectWithMasterFunction · 0.85

Tested by

no test coverage detected