table: clear StrategyInfo only if Strategy type differs
refs #3868
Change-Id: I164ccba3bd6c69cef9d2ebba303f8d8d941aac99
diff --git a/daemon/table/strategy-choice.cpp b/daemon/table/strategy-choice.cpp
index 77f0bf5..01756f5 100644
--- a/daemon/table/strategy-choice.cpp
+++ b/daemon/table/strategy-choice.cpp
@@ -219,14 +219,18 @@
void
StrategyChoice::changeStrategy(Entry& entry, Strategy& oldStrategy, Strategy& newStrategy)
{
- ///\todo #3868 don't clear StrategyInfo if only parameter differs
- if (&oldStrategy == &newStrategy) {
+ const Name& oldInstanceName = oldStrategy.getInstanceName();
+ const Name& newInstanceName = newStrategy.getInstanceName();
+ if (Strategy::areSameType(oldInstanceName, newInstanceName)) {
+ // same Strategy subclass type: no need to clear StrategyInfo
+ NFD_LOG_INFO("changeStrategy(" << entry.getPrefix() << ") "
+ << oldInstanceName << " -> " << newInstanceName
+ << " same-type");
return;
}
- NFD_LOG_INFO("changeStrategy(" << entry.getPrefix() << ")"
- << " from " << oldStrategy.getInstanceName()
- << " to " << newStrategy.getInstanceName());
+ NFD_LOG_INFO("changeStrategy(" << entry.getPrefix() << ") "
+ << oldInstanceName << " -> " << newInstanceName);
// reset StrategyInfo on a portion of NameTree,
// where entry's effective strategy is covered by the changing StrategyChoice entry