aboutsummaryrefslogtreecommitdiff
path: root/src/agent
diff options
context:
space:
mode:
authorSimon Lin <simonlin@google.com>2021-09-17 23:02:06 +0800
committerGitHub <noreply@github.com>2021-09-17 08:02:06 -0700
commit2599b3fa4581e512ce1c1b518d4c2edbbf0057b3 (patch)
tree060fd3dd57c21af831d54209cd2198c2e891fa8d /src/agent
parent9c5aa1c352a5e2b348f747a0dd8448da917dd9b0 (diff)
downloadot-br-posix-2599b3fa4581e512ce1c1b518d4c2edbbf0057b3.tar.gz
Revert "[advertising-proxy] handle duplicate hosts/services in SRP updates (#1008)" (#1014)
This reverts commit 685a1e0f483febc26127c8c2f2bd8f922b682a06.
Diffstat (limited to 'src/agent')
-rw-r--r--src/agent/advertising_proxy.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/agent/advertising_proxy.cpp b/src/agent/advertising_proxy.cpp
index 0d710fb7..bd87e642 100644
--- a/src/agent/advertising_proxy.cpp
+++ b/src/agent/advertising_proxy.cpp
@@ -161,15 +161,13 @@ void AdvertisingProxy::PublishServiceHandler(const char *aName, const char *aTyp
void AdvertisingProxy::PublishServiceHandler(const char *aName, const char *aType, otbrError aError)
{
- std::vector<OutstandingUpdate>::iterator next;
+ otbrError error = OTBR_ERROR_NONE;
otbrLogInfo("Handle publish service '%s.%s' result: %d", aName, aType, aError);
- // Note: There may be same service names in multiple SRP updates.
- for (auto update = mOutstandingUpdates.begin(); update != mOutstandingUpdates.end(); update = next)
+ // TODO: there may be same names between two SRP updates.
+ for (auto update = mOutstandingUpdates.begin(); update != mOutstandingUpdates.end(); ++update)
{
- next = update + 1;
-
for (const auto &nameAndType : update->mServiceNames)
{
if (aName != nameAndType.first || !Mdns::Publisher::IsServiceTypeEqual(aType, nameAndType.second.c_str()))
@@ -184,16 +182,22 @@ void AdvertisingProxy::PublishServiceHandler(const char *aName, const char *aTyp
// Erase before notifying OpenThread, because there are chances that new
// elements may be added to `otSrpServerHandleServiceUpdateResult` and
// the iterator will be invalidated.
- next = mOutstandingUpdates.erase(update);
+ mOutstandingUpdates.erase(update);
otSrpServerHandleServiceUpdateResult(GetInstance(), updateId, OtbrErrorToOtError(aError));
}
else
{
--update->mCallbackCount;
}
- break;
+ ExitNow();
}
}
+
+exit:
+ if (error != OTBR_ERROR_NONE)
+ {
+ otbrLogWarning("Failed to handle result of service %s", aName);
+ }
}
void AdvertisingProxy::PublishHostHandler(const char *aName, otbrError aError, void *aContext)
@@ -203,15 +207,12 @@ void AdvertisingProxy::PublishHostHandler(const char *aName, otbrError aError, v
void AdvertisingProxy::PublishHostHandler(const char *aName, otbrError aError)
{
- std::vector<OutstandingUpdate>::iterator next;
+ otbrError error = OTBR_ERROR_NONE;
otbrLogInfo("Handle publish host '%s' result: %d", aName, aError);
- // Note: There may be same host names in multiple SRP updates.
- for (auto update = mOutstandingUpdates.begin(); update != mOutstandingUpdates.end(); update = next)
+ for (auto update = mOutstandingUpdates.begin(); update != mOutstandingUpdates.end(); ++update)
{
- next = update + 1;
-
if (aName != update->mHostName)
{
continue;
@@ -224,13 +225,20 @@ void AdvertisingProxy::PublishHostHandler(const char *aName, otbrError aError)
// Erase before notifying OpenThread, because there are chances that new
// elements may be added to `otSrpServerHandleServiceUpdateResult` and
// the iterator will be invalidated.
- next = mOutstandingUpdates.erase(update);
+ mOutstandingUpdates.erase(update);
otSrpServerHandleServiceUpdateResult(GetInstance(), updateId, OtbrErrorToOtError(aError));
}
else
{
--update->mCallbackCount;
}
+ ExitNow();
+ }
+
+exit:
+ if (error != OTBR_ERROR_NONE)
+ {
+ otbrLogWarning("Failed to handle result of host %s", aName);
}
}