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. */
| 2585 | * |
| 2586 | * Otherwise zero is returned and no operation is performed at all. */ |
| 2587 | int 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. */ |
| 2613 | void replicationSetMaster(char *ip, int port) { |
no test coverage detected