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

Function connectWithMaster

src/replication.cpp:3806–3828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3804}
3805
3806int connectWithMaster(redisMaster *mi) {
3807 serverAssert(mi->master == nullptr);
3808 mi->repl_transfer_s = g_pserver->tls_replication ? connCreateTLS() : connCreateSocket();
3809 mi->ielReplTransfer = serverTL - g_pserver->rgthreadvar;
3810 connSetPrivateData(mi->repl_transfer_s, mi);
3811 if (connConnect(mi->repl_transfer_s, mi->masterhost, mi->masterport,
3812 NET_FIRST_BIND_ADDR, syncWithMaster) == C_ERR) {
3813 const char *err = "Unknown Error";
3814 if (mi->repl_transfer_s->last_errno != 0)
3815 err = connGetLastError(mi->repl_transfer_s);
3816 int sev = g_pserver->enable_multimaster ? LL_NOTICE : LL_WARNING; // with multimaster its not unheard of to intentionally have downed masters
3817 serverLog(sev, "Unable to connect to MASTER: %s", err);
3818 connClose(mi->repl_transfer_s);
3819 mi->repl_transfer_s = NULL;
3820 return C_ERR;
3821 }
3822
3823
3824 mi->repl_transfer_lastio = g_pserver->unixtime;
3825 mi->repl_state = REPL_STATE_CONNECTING;
3826 serverLog(LL_NOTICE,"MASTER <-> REPLICA sync started");
3827 return C_OK;
3828}
3829
3830/* This function can be called when a non blocking connection is currently
3831 * in progress to undo it.

Callers 4

replicationAddMasterFunction · 0.85
replicationCronFunction · 0.85

Calls 7

connCreateTLSFunction · 0.85
connCreateSocketFunction · 0.85
connSetPrivateDataFunction · 0.85
connConnectFunction · 0.85
connGetLastErrorFunction · 0.85
serverLogFunction · 0.85
connCloseFunction · 0.85

Tested by

no test coverage detected