-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix state machine handler race conditions introduced by
strand::wrap
(
#257) Approach What is the motivation for this PR? As the subject. Work item tracking Microsoft ADO (number only): 28585413 How did you do it? Post the handler directly to handler instead of calling it with strand::wrap How did you verify/test it? UT Any platform specific information? Documentation
- Loading branch information
1 parent
f7ef0fa
commit 2725e7c
Showing
10 changed files
with
635 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright 2021 (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <common/BoostAsioBehavior.h> | ||
#include <boost/asio.hpp> | ||
#include <boost/bind/bind.hpp> | ||
|
||
#include "FakeLinkManagerStateMachine.h" | ||
#include "common/MuxLogger.h" | ||
|
||
namespace test | ||
{ | ||
|
||
FakeLinkManagerStateMachine::FakeLinkManagerStateMachine( | ||
mux::MuxPort *muxPortPtr, | ||
boost::asio::io_service::strand &strand, | ||
common::MuxPortConfig &muxPortConfig | ||
) : | ||
link_manager::LinkManagerStateMachineBase( | ||
muxPortPtr, | ||
strand, | ||
muxPortConfig, | ||
{link_prober::LinkProberState::Label::Wait, | ||
mux_state::MuxState::Label::Wait, | ||
link_state::LinkState::Label::Down} | ||
) | ||
{ | ||
assert(muxPortPtr != nullptr); | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleSwssBladeIpv4AddressUpdate(boost::asio::ip::address address) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastSwssBladeIpv4Address = address; | ||
++mSwssBladeIpv4AddressUpdateHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleSwssSoCIpv4AddressUpdate(boost::asio::ip::address address) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastSwssSoCIpv4Address = address; | ||
++mSwssSoCIpv4AddressUpdateHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleGetServerMacAddressNotification(std::array<uint8_t, ETHER_ADDR_LEN> address) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastServerMacAddress = address; | ||
++mGetServerMacAddressNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleGetMuxStateNotification(mux_state::MuxState::Label label) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastGetMuxState = label; | ||
++mGetMuxStateNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleProbeMuxStateNotification(mux_state::MuxState::Label label) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastProbeMuxState = label; | ||
++mProbeMuxStateNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleMuxStateNotification(mux_state::MuxState::Label label) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastMuxStateNotification = label; | ||
++mMuxStateNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleSwssLinkStateNotification(const link_state::LinkState::Label label) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastSwssLinkState = label; | ||
++mSwssLinkStateNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handlePeerLinkStateNotification(const link_state::LinkState::Label label) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastPeerLinkState = label; | ||
++mPeerLinkStateNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handlePeerMuxStateNotification(mux_state::MuxState::Label label) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastPeerMuxState = label; | ||
++mPeerMuxStateNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleMuxConfigNotification(const common::MuxPortConfig::Mode mode) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastMuxConfig = mode; | ||
++mMuxConfigNotificationHandlerCalled; | ||
} | ||
|
||
void FakeLinkManagerStateMachine::handleDefaultRouteStateNotification(const DefaultRoute routeState) | ||
{ | ||
MUXLOGDEBUG(getMuxPortConfig().getPortName()); | ||
mLastDefaultRouteState = routeState; | ||
++mDefaultRouteStateNotificationHandlerCalled; | ||
} | ||
|
||
} /* namespace test */ |
Oops, something went wrong.