Merge lp:~afrantzis/mir/client-lifecycle-terminate-properly into lp:mir
Status: | Work in progress |
---|---|
Proposed branch: | lp:~afrantzis/mir/client-lifecycle-terminate-properly |
Merge into: | lp:mir |
Diff against target: |
653 lines (+169/-111) 16 files modified
include/test/mir_test_framework/basic_client_server_fixture.h (+2/-0) include/test/mir_test_framework/display_server_test_fixture.h (+2/-0) include/test/mir_test_framework/testing_process_manager.h (+3/-2) src/client/mir_connection.cpp (+6/-1) tests/acceptance-tests/test_client_input.cpp (+2/-0) tests/acceptance-tests/test_client_screencast.cpp (+7/-43) tests/acceptance-tests/test_client_surface_swap_buffers.cpp (+3/-15) tests/acceptance-tests/test_prompt_session_client_api.cpp (+2/-0) tests/acceptance-tests/test_server_disconnect.cpp (+60/-0) tests/acceptance-tests/test_server_shutdown.cpp (+2/-0) tests/acceptance-tests/test_stale_frames.cpp (+0/-2) tests/integration-tests/shell/test_session_lifecycle_event.cpp (+37/-48) tests/mir_test_framework/display_server_test_fixture.cpp (+5/-0) tests/mir_test_framework/testing_process_manager.cpp (+22/-0) tests/mir_test_framework/using_stub_client_platform.cpp (+5/-0) tests/unit-tests/client/test_client_mir_surface.cpp (+11/-0) |
To merge this branch: | bzr merge lp:~afrantzis/mir/client-lifecycle-terminate-properly |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Mir development team | Pending | ||
Review via email: mp+229234@code.launchpad.net |
Commit message
client: Fix SIGTERM dispatch in our default lifecycle event handler
Our default lifecycle event handler used to call raise() to send a TERM signal to the app when a connection break was detected. However, in a multi-threaded program raise() sends the signal to the current thread only. If the signal is blocked in that thread, then the signal is lost.
Depending on thread in which we detected that the connection was lost, the TERM signal would be dispatched (e.g. in the context of a driver callback asking for the next buffer) or not (e.g. in the context of our main RPC threads which block all signals). This MP fixes the issue by explicitly sending the signal to the process instead of the current thread. This ensures that it will be dispatched to some thread that doesn't block it.
Description of the change
client: Fix SIGTERM dispatch in our default lifecycle event handler
Our default lifecycle event handler used to call raise() to send a TERM signal to the app when a connection break was detected. However, in a multi-threaded program raise() sends the signal to the current thread only. If the signal is blocked in that thread, then the signal is lost.
Depending on thread in which we detected that the connection was lost, the TERM signal would be dispatched (e.g. in the context of a driver callback asking for the next buffer) or not (e.g. in the context of our main RPC threads which block all signals). This MP fixes the issue by explicitly sending the signal to the process instead of the current thread. This ensures that it will be dispatched to some thread that doesn't block it.
It turns out that we send a lifecycle connection lost event to ourselves when we release a client connection. With the signal dispatch issue fixed, this always leads to a SIGTERM being sent to the process when we call mir_connection_
I assumed that sending a lifecycle event on release is a behavior we want, i.e. it's not accidental. If it's indeed accidental, we can remove it, along with the workaround in this MP.
The workaround proposed in this MP is for our stub client platform (used in almost all the tests that use full clients) to clear any lifecycle handlers just prior to disconnecting. This has the benefit that the default handler is active for the lifetime of the client and can therefore catch premature disconnections. It's not ideal, but it's reasonable for now (IMO).
As part of the workaround I refactored some of the test code to use newer infrastructure (like BasicClientServ
Finally, this change fixes some instances of the "client spinning when the server dies" issue, which is especially pronounced if we apply https:/
Unmerged revisions
- 1811. By Alexandros Frantzis
-
client: Fix SIGTERM dispatch in our default lifecycle event handler
FAILED: Continuous integration, rev:1811 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- ci/2291/ jenkins. qa.ubuntu. com/job/ mir-android- utopic- i386-build/ 1171 jenkins. qa.ubuntu. com/job/ mir-clang- utopic- amd64-build/ 1177 jenkins. qa.ubuntu. com/job/ mir-mediumtests -utopic- touch/1159/ console jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- amd64-ci/ 813 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- amd64-ci/ 813/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- armhf-ci/ 814 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- utopic- armhf-ci/ 814/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- utopic- armhf/94 jenkins. qa.ubuntu. com/job/ mir-mediumtests -builder- utopic- armhf/94/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ mir-mediumtests -runner- mako/2281/ console s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 10857
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/mir- team-mir- development- branch- ci/2291/ rebuild
http://