Skip to content

Commit

Permalink
Maintain a synchronized DsfUpdate member in DsfSubscription.
Browse files Browse the repository at this point in the history
Summary:
This diff just trivially locks and moves the
received DSFUpdate into the synchronized member variable.
In stacked diffs, we will use this to synchronize b/w hwUpdate
and stream threads.

Reviewed By: peygar

Differential Revision:
D61231193

Privacy Context Container: L1125642

fbshipit-source-id: aa8176e28085cac2d49529ad855494e6bdf47476
  • Loading branch information
Jasmeet Bagga authored and facebook-github-bot committed Aug 14, 2024
1 parent 99eadb3 commit 2f8bc82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fboss/agent/DsfSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,16 @@ void DsfSubscription::handleFsdbUpdate(fsdb::OperSubPathUnit&& operStateUnit) {
remoteNodeName_);
}
}
updateWithRollbackProtection(
dsfUpdate.switchId2SystemPorts, dsfUpdate.switchId2Intfs);
{
auto nextDsfUpdateWlock = nextDsfUpdate_.wlock();
SCOPE_EXIT {
nextDsfUpdateWlock->clear();
};
*nextDsfUpdateWlock = std::move(dsfUpdate);
updateWithRollbackProtection(
nextDsfUpdateWlock->switchId2SystemPorts,
nextDsfUpdateWlock->switchId2Intfs);
}
}

bool DsfSubscription::isLocal(SwitchID nodeSwitchId) const {
Expand Down
1 change: 1 addition & 0 deletions fboss/agent/DsfSubscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class DsfSubscription {
folly::IPAddress remoteIp_;
SwSwitch* sw_;
DsfSession session_;
folly::Synchronized<DsfUpdate> nextDsfUpdate_;
// Used for tests only
std::shared_ptr<SwitchState> cachedState_;
template <typename T>
Expand Down

0 comments on commit 2f8bc82

Please sign in to comment.