diff options
Diffstat (limited to 'src/components/application_manager/src')
4 files changed, 46 insertions, 52 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 1ef6e5ceb8..97dcce10bf 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1418,16 +1418,6 @@ void ApplicationManagerImpl::SendMessageToMobile( << ") not allowed by policy"); return; } - - if (function_id == mobile_apis::FunctionID::OnSystemRequestID) { - mobile_apis::RequestType::eType request_type = - static_cast<mobile_apis::RequestType::eType>( - (*message)[strings::msg_params][strings::request_type].asUInt()); - if (mobile_apis::RequestType::PROPRIETARY == request_type || - mobile_apis::RequestType::HTTP == request_type) { - GetPolicyHandler().OnUpdateRequestSentToMobile(); - } - } } if (message_to_send->binary_data()) { diff --git a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc index fdf8b559bc..fdf8b559bc 100644..100755 --- a/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_button_press_notification.cc diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index cf312acc6d..23f5227667 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1130,6 +1130,8 @@ void PolicyHandler::OnSnapshotCreated(const BinaryMessage& pt_string) { } SendMessageToSDK(pt_string, urls.front().url.front()); #endif + // reset update required false + OnUpdateRequestSentToMobile(); } bool PolicyHandler::GetPriority(const std::string& policy_app_id, diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index cdf1616e42..aa2a3d7c5d 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -51,15 +51,20 @@ RequestController::RequestController(const RequestControlerSettings& settings) , pool_size_(settings.thread_pool_size()) , timer_("AM RequestCtrlTimer", new timer::TimerTaskImpl<RequestController>( - this, &RequestController::onTimer)) + this, &RequestController::TimeoutThread)) + , timer_stop_flag_(false) , is_low_voltage_(false) , settings_(settings) { LOG4CXX_AUTO_TRACE(logger_); InitializeThreadpool(); + timer_.Start(0, timer::kSingleShot); } RequestController::~RequestController() { LOG4CXX_AUTO_TRACE(logger_); + timer_stop_flag_ = true; + timer_condition_.Broadcast(); + timer_.Stop(); if (pool_state_ != TPoolState::STOPPED) { DestroyThreadpool(); } @@ -202,7 +207,7 @@ RequestController::TResult RequestController::addHMIRequest( LOG4CXX_DEBUG(logger_, "Waiting for response count:" << waiting_for_response_.Size()); - UpdateTimer(); + NotifyTimer(); return RequestController::SUCCESS; } @@ -252,7 +257,7 @@ void RequestController::TerminateRequest(const uint32_t correlation_id, } else { LOG4CXX_WARN(logger_, "Request was not terminated"); } - UpdateTimer(); + NotifyTimer(); } void RequestController::OnMobileResponse(const uint32_t mobile_correlation_id, @@ -307,7 +312,7 @@ void RequestController::terminateAppRequests(const uint32_t& app_id) { terminateWaitingForExecutionAppRequests(app_id); terminateWaitingForResponseAppRequests(app_id); - UpdateTimer(); + NotifyTimer(); } void RequestController::terminateAllHMIRequests() { @@ -322,7 +327,7 @@ void RequestController::terminateAllMobileRequests() { AutoLock waiting_execution_auto_lock(mobile_request_list_lock_); mobile_request_list_.clear(); LOG4CXX_DEBUG(logger_, "Mobile Requests waiting for execution cleared"); - UpdateTimer(); + NotifyTimer(); } void RequestController::updateRequestTimeout(const uint32_t& app_id, @@ -344,7 +349,7 @@ void RequestController::updateRequestTimeout(const uint32_t& app_id, waiting_for_response_.RemoveRequest(request_info); request_info->updateTimeOut(new_timeout); waiting_for_response_.Add(request_info); - UpdateTimer(); + NotifyTimer(); LOG4CXX_INFO(logger_, "Timeout updated for " << " app_id: " << app_id << " correlation_id: " @@ -375,14 +380,40 @@ bool RequestController::IsLowVoltage() { return is_low_voltage_; } -void RequestController::onTimer() { +void RequestController::TimeoutThread() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG( logger_, "ENTER Waiting fore response count: " << waiting_for_response_.Size()); - RequestInfoPtr probably_expired = - waiting_for_response_.FrontWithNotNullTimeout(); - while (probably_expired && probably_expired->isExpired()) { + while (!timer_stop_flag_) { + RequestInfoPtr probably_expired = + waiting_for_response_.FrontWithNotNullTimeout(); + if (!probably_expired) { + sync_primitives::AutoLock auto_lock(timer_lock); + timer_condition_.Wait(auto_lock); + continue; + } + if (!probably_expired->isExpired()) { + LOG4CXX_DEBUG(logger_, + "Timeout for " + << (RequestInfo::HMIRequest == + probably_expired->requst_type() + ? "HMI" + : "Mobile") + << " request id: " << probably_expired->requestId() + << " connection_key: " << probably_expired->app_id() + << " NOT expired"); + sync_primitives::AutoLock auto_lock(timer_lock); + const TimevalStruct current_time = date_time::DateTime::getCurrentTime(); + const TimevalStruct end_time = probably_expired->end_time(); + if (current_time < end_time) { + const uint32_t msecs = static_cast<uint32_t>( + date_time::DateTime::getmSecs(end_time - current_time)); + LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs"); + timer_condition_.WaitFor(auto_lock, msecs); + } + continue; + } LOG4CXX_INFO(logger_, "Timeout for " << (RequestInfo::HMIRequest == @@ -410,7 +441,6 @@ void RequestController::onTimer() { } } } - UpdateTimer(); LOG4CXX_DEBUG( logger_, "EXIT Waiting for response count : " << waiting_for_response_.Size()); @@ -461,7 +491,7 @@ void RequestController::Worker::threadMain() { LOG4CXX_DEBUG(logger_, "timeout_in_mseconds " << timeout_in_mseconds); if (0 != timeout_in_mseconds) { - request_controller_->UpdateTimer(); + request_controller_->NotifyTimer(); } else { LOG4CXX_DEBUG(logger_, "Default timeout was set to 0. " @@ -489,37 +519,9 @@ void RequestController::Worker::exitThreadMain() { // FIXME (dchmerev@luxoft.com): There is no waiting } -void RequestController::UpdateTimer() { +void RequestController::NotifyTimer() { LOG4CXX_AUTO_TRACE(logger_); - RequestInfoPtr front = waiting_for_response_.FrontWithNotNullTimeout(); - // Buffer for sending request - const uint32_t delay_time = 100u; - if (front) { - const TimevalStruct current_time = date_time::DateTime::getCurrentTime(); - TimevalStruct end_time = front->end_time(); - date_time::DateTime::AddMilliseconds(end_time, delay_time); - if (current_time < end_time) { - const uint32_t msecs = static_cast<uint32_t>( - date_time::DateTime::getmSecs(end_time - current_time)); - LOG4CXX_DEBUG(logger_, "Sleep for " << msecs << " millisecs"); - // Timeout for bigger than 5 minutes is a mistake - timer_.Start(msecs, timer::kSingleShot); - } else { - LOG4CXX_WARN( - logger_, - "Request app_id: " - << front->app_id() << " correlation_id: " << front->requestId() - << " is expired. " - << "End time (ms): " << date_time::DateTime::getmSecs(end_time) - << " Current time (ms): " - << date_time::DateTime::getmSecs(current_time) - << " Diff (current - end) (ms): " - << date_time::DateTime::getmSecs(current_time - end_time) - << " Request timeout (sec): " - << front->timeout_msec() / - date_time::DateTime::MILLISECONDS_IN_SECOND); - } - } + timer_condition_.NotifyOne(); } } // namespace request_controller |