MCPcopy Create free account
hub / github.com/Tencent/phxsql / ProcessWithSlaveMsg

Method ProcessWithSlaveMsg

phxbinlogsvr/core/repl/replication_slave.cpp:106–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106int ReplicationSlave::ProcessWithSlaveMsg() {
107 string recv_buff;
108 int ret = NetIO::Receive(ctx_->GetSlaveFD(), &recv_buff);
109 if (ret) {
110 ColorLogError("%s slave recv fail %d", __func__, ret);
111 STATISTICS(ReplRecvDataFail());
112 return SOCKET_FAIL;
113 }
114
115 if (recv_buff.size() == 0) {
116 ColorLogError("%s slave connect is lost", __func__);
117 return DATA_EMPTY;
118 }
119
120 ret = DealWithSlaveMsg(recv_buff);
121 if (ret)
122 return ret;
123
124 ret = NetIO::Send(ctx_->GetMasterFD(), recv_buff);
125 LogVerbose("%s send master buffer len %zu ret %d", __func__, recv_buff.size(), ret);
126 if (ret) {
127 STATISTICS(ReplSendDataFail());
128 return SOCKET_FAIL;
129 }
130
131 return OK;
132}
133
134int ReplicationSlave::DealWithSlaveMsg(string &recv_buff) {
135 COMMAND command_id = (COMMAND) recv_buff[4];

Callers

nothing calls this directly

Calls 4

ColorLogErrorFunction · 0.85
LogVerboseFunction · 0.85
GetSlaveFDMethod · 0.80
GetMasterFDMethod · 0.80

Tested by

no test coverage detected