summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Kalinich (GitHub) <AKalinich@luxoft.com>2020-10-26 14:01:53 -0400
committerGitHub <noreply@github.com>2020-10-26 14:01:53 -0400
commit54246454776513b68161258b46299b48e4352f3f (patch)
tree84edd8da919d2821ac00283bd2b7d75943c65628
parentc0b7d17b2ee650d7a4d36341c123840e02110822 (diff)
downloadsdl_core-54246454776513b68161258b46299b48e4352f3f.tar.gz
Fix a/v streaming retry sequence issues (#3552)
There were noticed two issues related to a/v streaming: 1. Due to object self destruction after TerminateRequest() call any attempt to access member field of that object may cause an undefined behavior - it might be a core crash or corrupted value sometimes. In this particular case, SDL tries to access `message_` field through `application_id()` function after object destruction. As a result, sometimes SDL crashes and sometimes this function just returns 0. Because of that, SDL was not able to find application by zero id and broke the retry sequence. This causes random failures of some ATF scripts. To avoid that issue, all retry logic was extracted into the separate function and `TerminateRequest` was moved after that function. This will guarantee that there is no attempts to access object fields after its destruction. 2. There was noticed that SDL makes one redundant retry attempt. That was because of late retry value increment. To fix that issue, increment has been placed before retry amount check.
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h2
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc63
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc63
4 files changed, 70 insertions, 60 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h
index fa9eee485e..ac6f1474e6 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_audio_start_stream_request.h
@@ -77,13 +77,13 @@ class AudioStartStreamRequest : public app_mngr::commands::RequestToHMI,
**/
virtual void on_event(const app_mngr::event_engine::Event& event);
+ private:
/**
* @brief RetryStartSession resend HMI startSession request if needed.
* If limit expired, set audio_stream_retry_number counter to 0
*/
void RetryStartSession();
- private:
uint32_t retry_number_;
DISALLOW_COPY_AND_ASSIGN(AudioStartStreamRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h
index afad744eb3..76413cd55d 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/navi_start_stream_request.h
@@ -77,13 +77,13 @@ class NaviStartStreamRequest : public app_mngr::commands::RequestToHMI,
*/
virtual void onTimeOut();
+ private:
/**
* @brief RetryStartSession resend HMI startSession request if needed.
* If limit expired, set video_stream_retry_number counter to 0
*/
void RetryStartSession();
- private:
uint32_t retry_number_;
DISALLOW_COPY_AND_ASSIGN(NaviStartStreamRequest);
};
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc
index b9860bcd02..21d6282436 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_audio_start_stream_request.cc
@@ -144,41 +144,46 @@ void AudioStartStreamRequest::onTimeOut() {
void AudioStartStreamRequest::RetryStartSession() {
SDL_LOG_AUTO_TRACE();
- application_manager_.TerminateRequest(
- connection_key(), correlation_id(), function_id());
+ auto retry_start_session = [this](const uint32_t hmi_app_id) {
+ ApplicationSharedPtr app =
+ application_manager_.application_by_hmi_app(hmi_app_id);
- ApplicationSharedPtr app =
- application_manager_.application_by_hmi_app(application_id());
- if (!app) {
- SDL_LOG_ERROR("StartAudioStreamRequest aborted. Application not found");
- return;
- }
+ if (!app) {
+ SDL_LOG_ERROR("StartAudioStreamRequest aborted. Application not found");
+ return;
+ }
- if (!app->audio_streaming_allowed()) {
- SDL_LOG_WARN("Audio streaming not allowed");
- return;
- }
+ if (!app->audio_streaming_allowed()) {
+ SDL_LOG_WARN("Audio streaming not allowed");
+ return;
+ }
- if (app->audio_streaming_approved()) {
- SDL_LOG_INFO("AudioStartStream retry sequence stopped. "
- << "SUCCESS received");
- app->set_audio_stream_retry_number(0);
- return;
- }
+ if (app->audio_streaming_approved()) {
+ SDL_LOG_INFO("AudioStartStream retry sequence stopped. "
+ << "SUCCESS received");
+ app->set_audio_stream_retry_number(0);
+ return;
+ }
- uint32_t curr_retry_number = app->audio_stream_retry_number();
+ uint32_t curr_retry_number = app->audio_stream_retry_number() + 1;
- if (curr_retry_number <= retry_number_) {
- SDL_LOG_DEBUG("Retry number " << curr_retry_number << " of "
- << retry_number_);
- MessageHelper::SendAudioStartStream(app->app_id(), application_manager_);
- app->set_audio_stream_retry_number(++curr_retry_number);
- } else {
- SDL_LOG_DEBUG("Audio start stream retry sequence stopped. "
- << "Attempts expired.");
+ if (curr_retry_number <= retry_number_) {
+ SDL_LOG_DEBUG("Retry number " << curr_retry_number << " of "
+ << retry_number_);
+ MessageHelper::SendAudioStartStream(app->app_id(), application_manager_);
+ app->set_audio_stream_retry_number(curr_retry_number);
+ } else {
+ SDL_LOG_DEBUG("Audio start stream retry sequence stopped. "
+ << "Attempts expired.");
- application_manager_.EndNaviServices(app->app_id());
- }
+ application_manager_.EndNaviServices(app->app_id());
+ }
+ };
+
+ retry_start_session(application_id());
+
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
} // namespace commands
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc
index d0f95ee385..973c323ebe 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/navi_start_stream_request.cc
@@ -146,41 +146,46 @@ void NaviStartStreamRequest::onTimeOut() {
void NaviStartStreamRequest::RetryStartSession() {
SDL_LOG_AUTO_TRACE();
- application_manager_.TerminateRequest(
- connection_key(), correlation_id(), function_id());
+ auto retry_start_session = [this](const uint32_t hmi_app_id) {
+ ApplicationSharedPtr app =
+ application_manager_.application_by_hmi_app(hmi_app_id);
- ApplicationSharedPtr app =
- application_manager_.application_by_hmi_app(application_id());
- if (!app) {
- SDL_LOG_ERROR("NaviStartStreamRequest aborted. Application not found");
- return;
- }
+ if (!app) {
+ SDL_LOG_ERROR("NaviStartStreamRequest aborted. Application not found");
+ return;
+ }
- if (!app->video_streaming_allowed()) {
- SDL_LOG_WARN("Video streaming not allowed");
- return;
- }
+ if (!app->video_streaming_allowed()) {
+ SDL_LOG_WARN("Video streaming not allowed");
+ return;
+ }
- if (app->video_streaming_approved()) {
- SDL_LOG_INFO("NaviStartStream retry sequence stopped. "
- << "SUCCESS received");
- app->set_video_stream_retry_number(0);
- return;
- }
+ if (app->video_streaming_approved()) {
+ SDL_LOG_INFO("NaviStartStream retry sequence stopped. "
+ << "SUCCESS received");
+ app->set_video_stream_retry_number(0);
+ return;
+ }
- uint32_t curr_retry_number = app->video_stream_retry_number();
+ uint32_t curr_retry_number = app->video_stream_retry_number() + 1;
- if (curr_retry_number <= retry_number_) {
- SDL_LOG_DEBUG("Retry number " << curr_retry_number << " of "
- << retry_number_);
- MessageHelper::SendNaviStartStream(app->app_id(), application_manager_);
- app->set_video_stream_retry_number(++curr_retry_number);
- } else {
- SDL_LOG_DEBUG("NaviStartStream retry sequence stopped. "
- << "Attempts expired");
+ if (curr_retry_number <= retry_number_) {
+ SDL_LOG_DEBUG("Retry number " << curr_retry_number << " of "
+ << retry_number_);
+ MessageHelper::SendNaviStartStream(app->app_id(), application_manager_);
+ app->set_video_stream_retry_number(curr_retry_number);
+ } else {
+ SDL_LOG_DEBUG("NaviStartStream retry sequence stopped. "
+ << "Attempts expired");
- application_manager_.EndNaviServices(app->app_id());
- }
+ application_manager_.EndNaviServices(app->app_id());
+ }
+ };
+
+ retry_start_session(application_id());
+
+ application_manager_.TerminateRequest(
+ connection_key(), correlation_id(), function_id());
}
} // namespace commands