| 166 | } |
| 167 | |
| 168 | int 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 | |
| 214 | int ReplicationSlave::DealWithSingalMsg(vector<string> &send_buffer) { |
| 215 | string recv_buff; |
nothing calls this directly
no test coverage detected