diff --git a/lib/remote/apilistener-authority.cpp b/lib/remote/apilistener-authority.cpp index f33a1905b..e169ad4b1 100644 --- a/lib/remote/apilistener-authority.cpp +++ b/lib/remote/apilistener-authority.cpp @@ -25,6 +25,7 @@ void ApiListener::UpdateObjectAuthority() std::vector endpoints; Endpoint::Ptr my_endpoint; + int hostChildrenInheritObjectAuthority = 0; if (my_zone) { my_endpoint = Endpoint::GetLocalEndpoint(); @@ -38,6 +39,10 @@ void ApiListener::UpdateObjectAuthority() continue; endpoints.push_back(endpoint); + + if (endpoint == my_endpoint || endpoint->GetCapabilities() & static_cast(ApiCapabilities::HostChildrenInheritObjectAuthority)) { + ++hostChildrenInheritObjectAuthority; + } } double startTime = Application::GetStartTime(); @@ -65,10 +70,24 @@ void ApiListener::UpdateObjectAuthority() bool authority; - if (!my_zone) + if (my_zone) { + auto name (object->GetName()); + + // If all endpoints know this algorithm, we can use it. + if (hostChildrenInheritObjectAuthority == endpoints.size()) { + auto exclamation (name.FindFirstOf('!')); + + // Pin child objects of hosts (HOST!...) to the same endpoint as the host. + // This reduces cross-object action latency withing the same host. + if (exclamation != String::NPos) { + name.erase(name.Begin() + exclamation, name.End()); + } + } + + authority = endpoints[Utility::SDBM(name) % endpoints.size()] == my_endpoint; + } else { authority = true; - else - authority = endpoints[Utility::SDBM(object->GetName()) % endpoints.size()] == my_endpoint; + } #ifdef I2_DEBUG // //Enable on demand, causes heavy logging on each run. diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 98b5c4968..4c0d006d8 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -640,7 +640,9 @@ static const auto l_AppVersionInt (([]() -> unsigned long { })()); static const auto l_MyCapabilities ( - (uint_fast64_t)ApiCapabilities::ExecuteArbitraryCommand | (uint_fast64_t)ApiCapabilities::IfwApiCheckCommand + (uint_fast64_t)ApiCapabilities::ExecuteArbitraryCommand + | (uint_fast64_t)ApiCapabilities::IfwApiCheckCommand + | (uint_fast64_t)ApiCapabilities::HostChildrenInheritObjectAuthority ); /** diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index eae1fa03e..bdb0fea52 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -69,6 +69,7 @@ enum class ApiCapabilities : uint_fast64_t { ExecuteArbitraryCommand = 1u << 0u, IfwApiCheckCommand = 1u << 1u, + HostChildrenInheritObjectAuthority = 1u << 2u, }; /**