| 392 | } |
| 393 | |
| 394 | void Instance :: OnReceive(const std::string & sBuffer) |
| 395 | { |
| 396 | BP->GetInstanceBP()->OnReceive(); |
| 397 | |
| 398 | if (sBuffer.size() <= 6) |
| 399 | { |
| 400 | PLGErr("buffer size %zu too short", sBuffer.size()); |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | Header oHeader; |
| 405 | size_t iBodyStartPos = 0; |
| 406 | size_t iBodyLen = 0; |
| 407 | int ret = Base::UnPackBaseMsg(sBuffer, oHeader, iBodyStartPos, iBodyLen); |
| 408 | if (ret != 0) |
| 409 | { |
| 410 | return; |
| 411 | } |
| 412 | |
| 413 | int iCmd = oHeader.cmdid(); |
| 414 | |
| 415 | if (iCmd == MsgCmd_PaxosMsg) |
| 416 | { |
| 417 | if (m_oCheckpointMgr.InAskforcheckpointMode()) |
| 418 | { |
| 419 | PLGImp("in ask for checkpoint mode, ignord paxosmsg"); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | PaxosMsg oPaxosMsg; |
| 424 | bool bSucc = oPaxosMsg.ParseFromArray(sBuffer.data() + iBodyStartPos, iBodyLen); |
| 425 | if (!bSucc) |
| 426 | { |
| 427 | BP->GetInstanceBP()->OnReceiveParseError(); |
| 428 | PLGErr("PaxosMsg.ParseFromArray fail, skip this msg"); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | if (!ReceiveMsgHeaderCheck(oHeader, oPaxosMsg.nodeid())) |
| 433 | { |
| 434 | return; |
| 435 | } |
| 436 | |
| 437 | OnReceivePaxosMsg(oPaxosMsg); |
| 438 | } |
| 439 | else if (iCmd == MsgCmd_CheckpointMsg) |
| 440 | { |
| 441 | CheckpointMsg oCheckpointMsg; |
| 442 | bool bSucc = oCheckpointMsg.ParseFromArray(sBuffer.data() + iBodyStartPos, iBodyLen); |
| 443 | if (!bSucc) |
| 444 | { |
| 445 | BP->GetInstanceBP()->OnReceiveParseError(); |
| 446 | PLGErr("PaxosMsg.ParseFromArray fail, skip this msg"); |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | if (!ReceiveMsgHeaderCheck(oHeader, oCheckpointMsg.nodeid())) |
| 451 | { |
nothing calls this directly
no test coverage detected