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

Method ProcessWithMasterMsg

phxbinlogsvr/core/repl/replication_slave.cpp:168–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168int ReplicationSlave::ProcessWithMasterMsg() {
169 do {
170 LogVerbose("%s get msg status %d", __func__, status_);
171 vector < string > send_buffer;
172 int ret = OK;
173 switch (status_) {
174 case CommandStatus::MSG:
175 ret = DealWithSingalMsg(send_buffer);
176 break;
177 case CommandStatus::QUERY:
178 ret = DealWithQuery(send_buffer);
179 break;
180 case CommandStatus::EVENT:
181 ret = DealWithEvent(send_buffer);
182 break;
183 case CommandStatus::RUNNING:
184 return OK;
185 default:
186 break;
187 }
188
189 if (status_ == CommandStatus::RUNNING && send_buffer.size() == 0) {
190 return OK;
191 }
192
193 if (send_buffer.size() == 0) {
194 return DATA_EMPTY;
195 }
196
197 if (ret == OK) {
198 for (size_t i = 0; i < send_buffer.size(); ++i) {
199 const string &recv_buff = send_buffer[i];
200 ret = NetIO::Send(ctx_->GetSlaveFD(), recv_buff);
201 if (ret) {
202 ColorLogError("%s send to slave fail, ret %d", __func__, ret);
203 STATISTICS(ReplSendDataFail());
204 break;
205 }
206 }
207 }
208 if (ret)
209 return ret;
210 } while (status_ == CommandStatus::EVENT);
211 return OK;
212}
213
214int ReplicationSlave::DealWithSingalMsg(vector<string> &send_buffer) {
215 string recv_buff;

Callers

nothing calls this directly

Calls 3

LogVerboseFunction · 0.85
ColorLogErrorFunction · 0.85
GetSlaveFDMethod · 0.80

Tested by

no test coverage detected