Skip to content

Commit

Permalink
fixup! [smclient] Reconnect on cert change
Browse files Browse the repository at this point in the history
  • Loading branch information
mlohvynenko committed Oct 17, 2024
1 parent c72fd6f commit a49ede5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/smclient/smclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ void SMClient::OnClockUnsynced()

void SMClient::OnCertChanged(const iam::certhandler::CertInfo& info)
{
LOG_DBG() << "Received on cert changed event: " << info;
LockGuard lock {mMutex};

LOG_DBG() << "Cert changed event received";

mCertificateChanged = true;
mCondVar.NotifyOne();
Expand Down Expand Up @@ -601,7 +603,7 @@ Error SMClient::SetupChannel()

#ifndef CONFIG_ZTEST
if (err = mCertHandler->SubscribeCertChanged(cSMCertType, *this); !err.IsNone()) {
return Error(AOS_ERROR_WRAP(err), "failed to subscribe on cert changed event");
return AOS_ERROR_WRAP(Error(err, "can't subscribe on cert changed event"));
}

if (err = mTLSChannel.Init("sm", *mCertHandler, *mCertLoader, *channel); !err.IsNone()) {
Expand Down Expand Up @@ -630,7 +632,11 @@ Error SMClient::SetupChannel()

Error SMClient::ReleaseChannel()
{
mCertificateChanged = false;
{
LockGuard lock {mMutex};

mCertificateChanged = false;
}

if (!IsStarted()) {
return ErrorEnum::eNone;
Expand All @@ -648,7 +654,7 @@ Error SMClient::ReleaseChannel()

#ifndef CONFIG_ZTEST
if (auto err = mCertHandler->UnsubscribeCertChanged(*this); !err.IsNone()) {
return Error(AOS_ERROR_WRAP(err), "failed to unsubscribe on cert changed event");
return AOS_ERROR_WRAP(Error(err, "can't unsubscribe from cert changed event"));
}
#endif

Expand Down

0 comments on commit a49ede5

Please sign in to comment.