From e3e9d15a38be5721c97ca98c67860056115e8152 Mon Sep 17 00:00:00 2001 From: Wang Qixiang <43193572+wqx6@users.noreply.github.com> Date: Tue, 2 Jul 2024 00:14:42 +0800 Subject: [PATCH] Reset the state of DiscoveryImplPlatform to Uninitialized when ChipDnssdInit fails (#34104) --- src/lib/dnssd/Discovery_ImplPlatform.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index a1b28b726614f9..beb733b1276a3f 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -419,7 +419,12 @@ CHIP_ERROR DiscoveryImplPlatform::InitImpl() VerifyOrReturnError(mState == State::kUninitialized, CHIP_NO_ERROR); mState = State::kInitializing; - ReturnErrorOnFailure(ChipDnssdInit(HandleDnssdInit, HandleDnssdError, this)); + CHIP_ERROR err = ChipDnssdInit(HandleDnssdInit, HandleDnssdError, this); + if (err != CHIP_NO_ERROR) + { + mState = State::kUninitialized; + return err; + } UpdateCommissionableInstanceName(); return CHIP_NO_ERROR;