diff options
author | Teodora Kireva <tkireva@luxoft.com> | 2017-02-24 13:58:18 +0200 |
---|---|---|
committer | Ira Lytvynenko <ILytvynenko@luxoft.com> | 2017-04-12 19:11:10 +0300 |
commit | 4bc13657066aab90cbcaccad3ab93daa652a1054 (patch) | |
tree | 8824184931bad90e9acb5be923c96d4cb1ed0020 | |
parent | 5202dea2dff80798431f7e477d179a2404328849 (diff) | |
download | sdl_core-4bc13657066aab90cbcaccad3ab93daa652a1054.tar.gz |
Fix omited URL in OnSystemRequest retry
The URL is skipped because of a new application is
registered and it is received the index of the default
section in the Endpoints vector. Fix compares the policy
application id of the application whose URL is about
to be sent from the Endpoints vector and from the member
variable in PolicyManager. If there is a difference,
the URL index is set to 0, so that no URL will be omited.
4 files changed, 30 insertions, 10 deletions
diff --git a/src/components/include/policy/policy_regular/policy/policy_types.h b/src/components/include/policy/policy_regular/policy/policy_types.h index 3405cf30d6..4e482b0e20 100644 --- a/src/components/include/policy/policy_regular/policy/policy_types.h +++ b/src/components/include/policy/policy_regular/policy/policy_types.h @@ -314,17 +314,20 @@ struct MetaInfo { }; /** - * @brief The index of the application and the index of its URL - * from the Endpoints vector that will be sent on the next - * OnSystemRequest retry sequence + * @brief The index of the application, the index of its URL + * and the policy application id from the Endpoints vector + * that will be sent on the next OnSystemRequest retry sequence */ struct RetrySequenceURL { int app_idx_; int url_idx_; - RetrySequenceURL(int app, int url) : app_idx_(app), url_idx_(url) {} + std::string policy_app_id_; + RetrySequenceURL(int app, int url, const std::string& app_id) + : app_idx_(app), url_idx_(url), policy_app_id_(app_id) {} RetrySequenceURL() { app_idx_ = 0; url_idx_ = 0; + policy_app_id_ = ""; } }; diff --git a/src/components/policy/policy_external/include/policy/policy_types.h b/src/components/policy/policy_external/include/policy/policy_types.h index 94898b2556..021e837196 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -365,17 +365,20 @@ struct MetaInfo { }; /** - * @brief The index of the application and the index of its URL - * from the Endpoints vector that will be sent on the next - * OnSystemRequest retry sequence + * @brief The index of the application, the index of its URL + * and the policy application id from the Endpoints vector + * that will be sent on the next OnSystemRequest retry sequence */ struct RetrySequenceURL { int app_idx_; int url_idx_; - RetrySequenceURL(int app, int url) : app_idx_(app), url_idx_(url) {} + std::string policy_app_id_; + RetrySequenceURL(int app, int url, const std::string& app_id) + : app_idx_(app), url_idx_(url), policy_app_id_(app_id) {} RetrySequenceURL() { app_idx_ = 0; url_idx_ = 0; + policy_app_id_ = ""; } } diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 3e1b28f5be..ad8ac881bd 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1199,6 +1199,7 @@ AppIdURL PolicyManagerImpl::GetNextUpdateUrl(const EndpointUrls& urls) { retry_sequence_url_.url_idx_ = next_app_url.second + 1; retry_sequence_url_.app_idx_ = next_app_url.first; + retry_sequence_url_.policy_app_id_ = urls[next_app_url.first].app_id; return next_app_url; } @@ -1207,8 +1208,14 @@ AppIdURL PolicyManagerImpl::RetrySequenceUrl(const struct RetrySequenceURL& rs, const EndpointUrls& urls) const { uint32_t url_idx = rs.url_idx_; uint32_t app_idx = rs.app_idx_; + const std::string app_id = rs.policy_app_id_; - if (url_idx >= urls[app_idx].url.size()) { + if (urls.size() <= app_idx) { + url_idx = 0; + app_idx = 0; + } else if (urls[app_idx].app_id != app_id) { + url_idx = 0; + } else if (url_idx >= urls[app_idx].url.size()) { url_idx = 0; if (++app_idx >= urls.size()) { app_idx = 0; diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index 2dc768dda0..926a9c5ab7 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -907,6 +907,7 @@ AppIdURL PolicyManagerImpl::GetNextUpdateUrl(const EndpointUrls& urls) { retry_sequence_url_.url_idx_ = next_app_url.second + 1; retry_sequence_url_.app_idx_ = next_app_url.first; + retry_sequence_url_.policy_app_id_ = urls[next_app_url.first].app_id; return next_app_url; } @@ -915,8 +916,14 @@ AppIdURL PolicyManagerImpl::RetrySequenceUrl(const struct RetrySequenceURL& rs, const EndpointUrls& urls) const { uint32_t url_idx = rs.url_idx_; uint32_t app_idx = rs.app_idx_; + const std::string app_id = rs.policy_app_id_; - if (url_idx >= urls[app_idx].url.size()) { + if (urls.size() <= app_idx) { + url_idx = 0; + app_idx = 0; + } else if (urls[app_idx].app_id != app_id) { + url_idx = 0; + } else if (url_idx >= urls[app_idx].url.size()) { url_idx = 0; if (++app_idx >= urls.size()) { app_idx = 0; |