Skip to content

Commit

Permalink
Fix various issues
Browse files Browse the repository at this point in the history
Signed-off-by: Longxiang Lyu <[email protected]>
  • Loading branch information
lolyu committed Apr 25, 2022
1 parent 5a861ec commit 8608abe
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/link_manager/LinkManagerStateMachineActiveActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,13 @@ void ActiveActiveStateMachine::handleMuxConfigNotification(const common::MuxPort
{
if (mComponentInitState.all()) {
CompositeState nextState = mCompositeState;
if (mode == common::MuxPortConfig::Mode::Active &&
ms(mCompositeState) != mux_state::MuxState::Label::Active) {
if (mode == common::MuxPortConfig::Mode::Active && ms(mCompositeState) != mux_state::MuxState::Label::Active) {
switchMuxState(nextState, mux_state::MuxState::Label::Active);
} else if (mode == common::MuxPortConfig::Mode::Standby && ms(mCompositeState) != mux_state::MuxState::Label::Standby) {
switchMuxState(nextState, mux_state::MuxState::Label::Standby);
} else {
// enforce link prober state to match mux state to trigger possible transitions
initLinkProberState(nextState);
mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::DriverUpdate);
probeMuxState();
}
LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState);
Expand Down Expand Up @@ -396,8 +395,7 @@ void ActiveActiveStateMachine::handlePeerStateChange(
link_prober::LinkProberState::Label state
)
{
link_prober::LinkProberState *currentPeerState = std::dynamic_pointer_cast<link_prober::LinkProberStateMachineActiveActive>(mLinkProberStateMachinePtr)->getCurrentPeerState();
if ((dynamic_cast<link_state::LinkState *>(mLinkProberStateMachinePtr->getCurrentPeerState()))->getStateLabel() == state) {
if ((dynamic_cast<link_prober::LinkProberState *>(mLinkProberStateMachinePtr->getCurrentPeerState()))->getStateLabel() == state) {
MUXLOGWARNING(
boost::format("%s: Received peer link prober event, new state: %s") %
mMuxPortConfig.getPortName() %
Expand Down Expand Up @@ -521,16 +519,6 @@ void ActiveActiveStateMachine::LinkProberActiveMuxStandbyLinkUpTransitionFunctio
switchMuxState(nextState, mux_state::MuxState::Label::Active);
}

// void ActiveActiveStateMachine::LinkProberActiveMuxUnknownLinkUpTransitionFunction(CompositeState &nextState)
// {
// MUXLOGINFO(mMuxPortConfig.getPortName());
// if (ps(mCompositeState) != link_prober::LinkProberState::Active) {
// switchMuxState(nextState, mux_state::MuxState::Label::Active);
// } else {
// probeMuxState();
// }
// }

//
// ---> LinkProberUnknownMuxActiveLinkUpTransitionFunction(CompositeState &nextState);
//
Expand All @@ -550,7 +538,11 @@ void ActiveActiveStateMachine::LinkProberUnknownMuxActiveLinkUpTransitionFunctio
void ActiveActiveStateMachine::LinkProberActiveMuxUnknownLinkUpTransitionFunction(CompositeState &nextState)
{
MUXLOGINFO(mMuxPortConfig.getPortName());
probeMuxState();
if (ps(mCompositeState) != link_prober::LinkProberState::Active) {
switchMuxState(nextState, mux_state::MuxState::Label::Active);
} else {
probeMuxState();
}
}

//
Expand All @@ -561,7 +553,11 @@ void ActiveActiveStateMachine::LinkProberActiveMuxUnknownLinkUpTransitionFunctio
void ActiveActiveStateMachine::LinkProberUnknownMuxUnknownLinkUpTransitionFunction(CompositeState &nextState)
{
MUXLOGINFO(mMuxPortConfig.getPortName());
probeMuxState();
if (ps(mCompositeState) != link_prober::LinkProberState::Unknown) {
switchMuxState(nextState, mux_state::MuxState::Label::Standby);
} else {
probeMuxState();
}
}

//
Expand Down Expand Up @@ -776,6 +772,9 @@ void ActiveActiveStateMachine::initLinkProberState(CompositeState &compositeStat
case mux_state::MuxState::Label::Error:
enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Wait);
break;
case mux_state::MuxState::Label::Wait:
enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Wait);
break;
default:
break;
}
Expand All @@ -801,6 +800,9 @@ void ActiveActiveStateMachine::initPeerLinkProberState()
case mux_state::MuxState::Label::Error:
enterPeerLinkProberState(link_prober::LinkProberState::Label::PeerWait);
break;
case mux_state::MuxState::Label::Wait:
enterPeerLinkProberState(link_prober::LinkProberState::Label::PeerWait);
break;
default:
break;
}
Expand Down

0 comments on commit 8608abe

Please sign in to comment.