Skip to content

Commit

Permalink
Don't lose enableServerInteractions state when controller restarts. (#…
Browse files Browse the repository at this point in the history
…16504)

When we shut down and restart the last controller, we shut down and
reinitialize the system state.  Since we were not storing the
enableServerInteractions state in either the SystemState or the
CHIPDeviceControllerFactory, it was getting lost during this process.

The fix is to store the state in CHIPDeviceControllerFactory.
  • Loading branch information
bzbarsky-apple authored Mar 22, 2022
1 parent feb81b6 commit d71e8e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ CHIP_ERROR DeviceControllerFactory::Init(FactoryInitParams params)
return CHIP_NO_ERROR;
}

// Save our initialization state that we can't recover later from a
// created-but-shut-down system state.
mListenPort = params.listenPort;
mFabricIndependentStorage = params.fabricIndependentStorage;
mEnableServerInteractions = params.enableServerInteractions;

CHIP_ERROR err = InitSystemState(params);

Expand All @@ -74,10 +77,11 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState()
#if CONFIG_NETWORK_LAYER_BLE
params.bleLayer = mSystemState->BleLayer();
#endif
params.listenPort = mListenPort;
params.fabricIndependentStorage = mFabricIndependentStorage;
params.enableServerInteractions = mEnableServerInteractions;
}

params.fabricIndependentStorage = mFabricIndependentStorage;

return InitSystemState(params);
}

Expand Down Expand Up @@ -128,12 +132,12 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
//
ReturnErrorOnFailure(stateParams.transportMgr->Init(Transport::UdpListenParameters(stateParams.udpEndPointManager)
.SetAddressType(Inet::IPAddressType::kIPv6)
.SetListenPort(mListenPort)
.SetListenPort(params.listenPort)
#if INET_CONFIG_ENABLE_IPV4
,
Transport::UdpListenParameters(stateParams.udpEndPointManager)
.SetAddressType(Inet::IPAddressType::kIPv4)
.SetListenPort(mListenPort)
.SetListenPort(params.listenPort)
#endif
#if CONFIG_NETWORK_LAYER_BLE
,
Expand Down
1 change: 1 addition & 0 deletions src/controller/CHIPDeviceControllerFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class DeviceControllerFactory
uint16_t mListenPort;
DeviceControllerSystemState * mSystemState = nullptr;
PersistentStorageDelegate * mFabricIndependentStorage = nullptr;
bool mEnableServerInteractions = false;
};

} // namespace Controller
Expand Down

0 comments on commit d71e8e5

Please sign in to comment.