Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SDL behavior during low voltage #3029

Merged
merged 1 commit into from
Sep 24, 2019

Conversation

AKalinich-Luxoft
Copy link
Contributor

@AKalinich-Luxoft AKalinich-Luxoft commented Sep 13, 2019

Fixes #2996

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

Covered by ATF test scripts

Summary

There were found a several problems during SDL testing with ATF scripts:

  1. SDL ignores messages from mobile/HMI during low voltage but as they are still delivered to the independent external container (e.g. socket) during Low Voltage - when SDL wakes up - it is not aware what data was in the container and starts processing them.
  2. Sometimes SDL ignores messages on wake up due to timings
  3. SDL low voltage process is not stopping properly by exit() function
  4. SDL does not send OnAppUnregistered after wake up to HMI

To solve mentioned problems, the following changes were done:

  1. exit() was replaced with _Exit() which allow to force close the child process which has fully done its job.
  2. Suspend transport events processing threads during low voltage, such as unexpected disconnect etc. These events should be processed when SDL wakes up completely.
  3. Suspend all client listening threads and shut down sockets for a TCP connections to prevent any possibility to receive message during low voltage. These threads will be resumed on wake up.
  4. Set low_voltage flag to false in the end of wakeup() function to prevent any timing issues.
  5. Don't add pending requests/notifications into request controller if low voltage event has happened, as it may happen at any moment
  6. Don't handle received pending messages from mobile/HMI in RPC handler if low voltage event has happened as it may happen at any moment

CLA

@AByzhynar
Copy link
Contributor

@theresalech PR is ready for Livio team review. Thank you.

@dboltovskyi
Copy link
Contributor

@theresalech Please notice there is an update in scripts related to the issue which needs to be taken into account as well: smartdevicelink/sdl_atf_test_scripts#2261

@iCollin
Copy link
Collaborator

iCollin commented Sep 17, 2019

There is quite a bit of duplicated code in this PR. It would be more maintainable to add a parameter to existing functions in Transport Manager, Transport Adapter and TCP Client Listener that determines the functionality than to have these duplicate functions.

  1. Suspend all client listening threads and shut down sockets for a TCP connections to prevent any possibility to receive message during low voltage. These threads will be resumed on wake up.

While shutting down sockets was added in this PR, the TCP Client Listener thread will be joined in both current version and this branch. In fact, this PR removes the joining of the Interface Listener thread which is happening currently.

@AByzhynar
Copy link
Contributor

@iCollin Please check the reply. Thank you.

There is quite a bit of duplicated code in this PR. It would be more maintainable to add a parameter to existing functions in Transport Manager, Transport Adapter and TCP Client Listener that determines the functionality than to have these duplicate functions.

Sure. You are right. We will try to combine duplicated code into functions.

  1. Suspend all client listening threads and shut down sockets for a TCP connections to prevent any possibility to receive message during low voltage. These threads will be resumed on wake up.

While shutting down sockets was added in this PR, the TCP Client Listener thread will be joined in both current version and this branch. In fact, this PR removes the joining of the Interface Listener thread which is happening currently.

This was made intentionally as all the threads will be suspended during Low Voltage and all we need to do is just shutdown and close appropriate sockets and re-create them on WakeUp. So when the thread will be woken up - it will use new socket.

@theresalech
Copy link
Contributor

@AByzhynar please let us know when this is ready for re-review

@AByzhynar
Copy link
Contributor

AByzhynar commented Sep 20, 2019

@iCollin Duplicated code removed in 768a22c

@AByzhynar
Copy link
Contributor

@theresalech PR is ready for re-review

@AByzhynar
Copy link
Contributor

AByzhynar commented Sep 20, 2019

@iCollin Please don't merge after approval. I would like to squash commits to make history clear and understandable. Just APPROVE - and I will squash them and let you know that PR can be merged. Thank you.

@AByzhynar AByzhynar requested a review from iCollin September 20, 2019 13:10
@iCollin
Copy link
Collaborator

iCollin commented Sep 20, 2019

@iCollin Please don't merge after approval. I would like to squash commits to make history clear and understandable. Just APPROVE - and I will squash them and let you know that PR can be merged. Thank you.

I will squash and merge after I approve this PR, should get around to review in a few hours.

@AByzhynar
Copy link
Contributor

AByzhynar commented Sep 20, 2019

@iCollin Please don't merge after approval. I would like to squash commits to make history clear and understandable. Just APPROVE - and I will squash them and let you know that PR can be merged. Thank you.

I will squash and merge after I approve this PR, should get around to review in a few hours.

Ok. Thank you. We have checked all unit tests as well as all regression tests.

} else {
ret = (*it)->StopClientListening();
}
(*it)->ChangeClientListening(required_action);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(*it)->ChangeClientListening(required_action);
ret = (*it)->ChangeClientListening(required_action);

There were found a several problems during SDL testing with ATF scripts:
1. SDL does not ignore messages from mobile/HMI during low voltage and
processes them on wake up
2. Sometimes SDL ignores messages on wake up due to timings
3. SDL low voltage process is not stopping properly by exit() function
4. SDL does not send OnAppUnregistered after wake up to HMI

To solve mentioned problems, the following changes were done:
1.  exit() was replaced with _Exit() which allow to force close the
process
2. Suspend transport events processing threads during low voltage,
such as unexpected disconnect etc. These events should be processed
when SDL wakes up completely.
3. Suspend all client listening threads and shut down sockets for a TCP
connections to prevent any possibility to receive message during low
voltage. These threads will be resumed on wake up.
4.  Set low_voltage flag to false in the end of wakeup() function to
prevent any timing issues.
5. Don't add pending requests/notifications into request controller if
low voltage event has happened, as it may happen at any moment
6. Don't handle received pending messages from mobile/HMI  in RPC
handler if low voltage event has happened as it may happen at any
moment

7. Updated logic of few test case scenarios.
   Updated unit tests according to code changes
@AByzhynar AByzhynar force-pushed the fix/fix_sdl_low_voltage_behavior branch from 107b8ad to 8c71bbb Compare September 24, 2019 14:31
}
TransportAdapter::Error ret = TransportAdapter::Error::UNKNOWN;

for (auto adapter_ptr : transport_adapters_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iCollin I have updated the code and make it even more short and simple

TransportAdapter::Error ret = TransportAdapter::Error::UNKNOWN;

for (auto adapter_ptr : transport_adapters_) {
ret = adapter_ptr->ChangeClientListening(required_action);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iCollin as well as here

@iCollin
Copy link
Collaborator

iCollin commented Sep 24, 2019

We would appreciate if you did not force push on sdl_core repository. It makes it difficult to review a PR because we cannot tell what was changed since the last review. In general, please do not rebase, do not force push against sdl_core. Instead, you can merge the current develop branch into your PR branch. Please pass this information along to your team members. Thank you

@iCollin iCollin merged commit b454f5c into develop Sep 24, 2019
@iCollin iCollin deleted the fix/fix_sdl_low_voltage_behavior branch September 24, 2019 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.