Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
  • Loading branch information
lolyu committed Jul 2, 2024
1 parent 80b20f4 commit 0cea2fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
30 changes: 12 additions & 18 deletions src/link_manager/LinkManagerStateMachineActiveStandby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,15 @@ void ActiveStandbyStateMachine::handleStateChange(LinkProberEvent &event, link_p

mStandbyUnknownUpCount = 0;

if (mOscillationTimerAlive) {
cancelOscillationTimer();
}
tryCancelOscillationTimerIfAlive();
}

if (state == link_prober::LinkProberState::Label::Standby) {
mMuxPortPtr->postLinkProberMetricsEvent(link_manager::ActiveStandbyStateMachine::LinkProberMetrics::LinkProberStandbyStart);

mActiveUnknownUpCount = 0;

if (mOscillationTimerAlive) {
cancelOscillationTimer();
}
tryCancelOscillationTimerIfAlive();
}

CompositeState nextState = mCompositeState;
Expand Down Expand Up @@ -548,9 +544,7 @@ void ActiveStandbyStateMachine::handleStateChange(MuxStateEvent &event, mux_stat
mStandbyUnknownUpCount = 0;
}

if (state == mux_state::MuxState::Label::Standby && mOscillationTimerAlive) {
cancelOscillationTimer();
}
tryCancelOscillationTimerIfAlive();

updateMuxLinkmgrState();
}
Expand Down Expand Up @@ -593,9 +587,7 @@ void ActiveStandbyStateMachine::handleStateChange(LinkStateEvent &event, link_st
mWaitStandbyUpBackoffFactor = 1;
mUnknownActiveUpBackoffFactor = 1;

if (mOscillationTimerAlive) {
cancelOscillationTimer();
}
tryCancelOscillationTimerIfAlive();
} else {
mStateTransitionHandler[ps(nextState)][ms(nextState)][ls(nextState)](nextState);
}
Expand Down Expand Up @@ -1091,15 +1083,17 @@ void ActiveStandbyStateMachine::startOscillationTimer()
}

//
// ---> cancelOscillationTimer();
// ---> tryCancelOscillationTimerIfAlive();
//
// cancel the oscillation timer
// cancel the oscillation timer if it is alive
//
void ActiveStandbyStateMachine::cancelOscillationTimer()
void ActiveStandbyStateMachine::tryCancelOscillationTimerIfAlive()
{
MUXLOGINFO(boost::format("%s: cancel the oscillation timer") % mMuxPortConfig.getPortName());
mOscillationTimerAlive = false;
mOscillationTimer.cancel();
if (mOscillationTimerAlive) {
MUXLOGINFO(boost::format("%s: cancel the oscillation timer") % mMuxPortConfig.getPortName());
mOscillationTimerAlive = false;
mOscillationTimer.cancel();
}
}

//
Expand Down
6 changes: 3 additions & 3 deletions src/link_manager/LinkManagerStateMachineActiveStandby.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,13 @@ class ActiveStandbyStateMachine: public LinkManagerStateMachineBase,
void startOscillationTimer();

/**
*@method cancelOscillationTimer
*@method tryCancelOscillationTimerIfAlive
*
*@brief cancel the oscillation timer
*@brief cancel the oscillation timer if it is alive
*
*@return none
*/
inline void cancelOscillationTimer();
inline void tryCancelOscillationTimerIfAlive();

/**
*@method handleOscillationTimeout
Expand Down

0 comments on commit 0cea2fb

Please sign in to comment.