File tree 4 files changed +24
-10
lines changed
4 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,9 @@ void DnssdServer::StartServer()
345
345
346
346
void DnssdServer::StopServer ()
347
347
{
348
+ // Make sure we don't hold on to a dangling fabric table pointer.
349
+ mFabricTable = nullptr ;
350
+
348
351
DeviceLayer::PlatformMgr ().RemoveEventHandler (OnPlatformEventWrapper, 0 );
349
352
350
353
#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
Original file line number Diff line number Diff line change @@ -60,8 +60,9 @@ class DLL_EXPORT DnssdServer
60
60
Inet::InterfaceId GetInterfaceId () { return mInterfaceId ; }
61
61
62
62
//
63
- // Override the referenced fabric table from the default that is present
64
- // in Server::GetInstance().GetFabricTable() to something else.
63
+ // Set the fabric table the DnssdServer should use for operational
64
+ // advertising. This must be set before StartServer() is called for the
65
+ // first time.
65
66
//
66
67
void SetFabricTable (FabricTable * table)
67
68
{
@@ -94,7 +95,8 @@ class DLL_EXPORT DnssdServer
94
95
// / (Re-)starts the Dnssd server, using the provided commissioning mode.
95
96
void StartServer (Dnssd::CommissioningMode mode);
96
97
97
- // // Stop the Dnssd server.
98
+ // // Stop the Dnssd server. After this call, SetFabricTable must be called
99
+ // // again before calling StartServer().
98
100
void StopServer ();
99
101
100
102
CHIP_ERROR GenerateRotatingDeviceId (char rotatingDeviceIdHexBuffer[], size_t rotatingDeviceIdHexBufferSize);
Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
272
272
273
273
// store the system state
274
274
mSystemState = chip::Platform::New<DeviceControllerSystemState>(std::move (stateParams));
275
- mSystemState ->SetTempFabricTable (tempFabricTable);
275
+ mSystemState ->SetTempFabricTable (tempFabricTable, params. enableServerInteractions );
276
276
ChipLogDetail (Controller, " System State Initialized..." );
277
277
return CHIP_NO_ERROR;
278
278
}
@@ -348,11 +348,6 @@ void DeviceControllerFactory::RetainSystemState()
348
348
void DeviceControllerFactory::ReleaseSystemState ()
349
349
{
350
350
mSystemState ->Release ();
351
-
352
- if (!mSystemState ->IsInitialized () && mEnableServerInteractions )
353
- {
354
- app::DnssdServer::Instance ().StopServer ();
355
- }
356
351
}
357
352
358
353
DeviceControllerFactory::~DeviceControllerFactory ()
@@ -384,6 +379,14 @@ void DeviceControllerSystemState::Shutdown()
384
379
385
380
ChipLogDetail (Controller, " Shutting down the System State, this will teardown the CHIP Stack" );
386
381
382
+ if (mTempFabricTable && mEnableServerInteractions )
383
+ {
384
+ // The DnssdServer is holding a reference to our temp fabric table,
385
+ // which we are about to destroy. Stop it, so that it will stop trying
386
+ // to use it.
387
+ app::DnssdServer::Instance ().StopServer ();
388
+ }
389
+
387
390
if (mFabricTableDelegate != nullptr )
388
391
{
389
392
if (mFabrics != nullptr )
Original file line number Diff line number Diff line change @@ -185,7 +185,11 @@ class DeviceControllerSystemState
185
185
CASESessionManager * CASESessionMgr () const { return mCASESessionManager ; }
186
186
Credentials::GroupDataProvider * GetGroupDataProvider () const { return mGroupDataProvider ; }
187
187
Crypto::SessionKeystore * GetSessionKeystore () const { return mSessionKeystore ; }
188
- void SetTempFabricTable (FabricTable * tempFabricTable) { mTempFabricTable = tempFabricTable; }
188
+ void SetTempFabricTable (FabricTable * tempFabricTable, bool enableServerInteractions)
189
+ {
190
+ mTempFabricTable = tempFabricTable;
191
+ mEnableServerInteractions = enableServerInteractions;
192
+ }
189
193
190
194
private:
191
195
DeviceControllerSystemState () {}
@@ -220,6 +224,8 @@ class DeviceControllerSystemState
220
224
221
225
bool mHaveShutDown = false ;
222
226
227
+ bool mEnableServerInteractions = false ;
228
+
223
229
void Shutdown ();
224
230
};
225
231
You can’t perform that action at this time.
0 commit comments