summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular/src/policy_manager_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_regular/src/policy_manager_impl.cc')
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc29
1 files changed, 23 insertions, 6 deletions
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 6871a5c416..5b9856193e 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -316,6 +316,7 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
FilterPolicyTable(pt_update->policy_table);
if (!IsPTValid(pt_update, policy_table::PT_UPDATE)) {
wrong_ptu_update_received_ = true;
+ ResetRetrySequence(ResetRetryCountType::kResetInternally);
update_status_manager_.OnWrongUpdateReceived();
return false;
}
@@ -519,7 +520,7 @@ void PolicyManagerImpl::GetUpdateUrls(const uint32_t service_type,
cache_->GetUpdateUrls(service_type, out_end_points);
}
-bool PolicyManagerImpl::RequestPTUpdate() {
+bool PolicyManagerImpl::RequestPTUpdate(const PTUIterationType iteration_type) {
LOG4CXX_AUTO_TRACE(logger_);
std::shared_ptr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
@@ -538,7 +539,7 @@ bool PolicyManagerImpl::RequestPTUpdate() {
BinaryMessage update(message_string.begin(), message_string.end());
- listener_->OnSnapshotCreated(update);
+ listener_->OnSnapshotCreated(update, iteration_type);
return true;
}
@@ -580,7 +581,8 @@ void PolicyManagerImpl::StartPTExchange() {
}
if (update_status_manager_.IsUpdateRequired()) {
- if (RequestPTUpdate() && !timer_retry_sequence_.is_running()) {
+ if (RequestPTUpdate(PTUIterationType::DefaultIteration) &&
+ !timer_retry_sequence_.is_running()) {
// Start retry sequency
const uint32_t timeout_msec = NextRetryTimeout();
@@ -1192,6 +1194,7 @@ std::string PolicyManagerImpl::GetPolicyTableStatus() const {
}
uint32_t PolicyManagerImpl::NextRetryTimeout() {
+ LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
LOG4CXX_DEBUG(logger_, "Index: " << retry_sequence_index_);
uint32_t next = 0u;
@@ -1224,10 +1227,14 @@ void PolicyManagerImpl::RefreshRetrySequence() {
cache_->SecondsBetweenRetries(retry_sequence_seconds_);
}
-void PolicyManagerImpl::ResetRetrySequence() {
+void PolicyManagerImpl::ResetRetrySequence(
+ const ResetRetryCountType reset_type) {
+ LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock auto_lock(retry_sequence_lock_);
retry_sequence_index_ = 0;
- update_status_manager_.OnResetRetrySequence();
+ if (ResetRetryCountType::kResetWithStatusUpdate == reset_type) {
+ update_status_manager_.OnResetRetrySequence();
+ }
}
uint32_t PolicyManagerImpl::TimeoutExchangeMSec() {
@@ -1496,6 +1503,11 @@ uint32_t PolicyManagerImpl::HeartBeatTimeout(const std::string& app_id) const {
}
void PolicyManagerImpl::SaveUpdateStatusRequired(bool is_update_needed) {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!is_update_needed) {
+ ResetRetrySequence(ResetRetryCountType::kResetInternally);
+ }
cache_->SaveUpdateRequired(is_update_needed);
}
@@ -1513,6 +1525,11 @@ void PolicyManagerImpl::StartRetrySequence() {
if (is_exceeded_retries_count) {
LOG4CXX_WARN(logger_, "Exceeded allowed PTU retry count");
listener_->OnPTUTimeOut();
+ ResetRetrySequence(ResetRetryCountType::kResetWithStatusUpdate);
+ if (timer_retry_sequence_.is_running()) {
+ timer_retry_sequence_.Stop();
+ }
+ return;
}
update_status_manager_.OnUpdateTimeoutOccurs();
@@ -1526,7 +1543,7 @@ void PolicyManagerImpl::StartRetrySequence() {
return;
}
- RequestPTUpdate();
+ RequestPTUpdate(PTUIterationType::RetryIteration);
timer_retry_sequence_.Start(timeout_msec, timer::kPeriodic);
}