Mir

Merge lp:~alan-griffiths/mir/fix-1377968 into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Nick Dedekind
Approved revision: no longer in the source branch.
Merged at revision: 1967
Proposed branch: lp:~alan-griffiths/mir/fix-1377968
Merge into: lp:mir
Diff against target: 77 lines (+33/-8)
3 files modified
src/server/scene/prompt_session_manager_impl.cpp (+14/-8)
tests/acceptance-tests/test_prompt_session_client_api.cpp (+17/-0)
tests/integration-tests/frontend/test_session_mediator_report.cpp (+2/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1377968
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Approve
Andreas Pokorny (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+237287@code.launchpad.net

Commit message

trusted prompt sessions: starting a prompt session with an invalid application pid reports an error

Description of the change

trusted prompt sessions: starting a prompt session with an invalid application pid reports an error

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

36 + prompt_session_container->insert_participant(prompt_session.get(), application_session, PromptSessionContainer::ParticipantType::application);

Indentation.

ServerShutdownWithThreadException.server_releases_resources_on_abnormal_compositor_thread_termination doesn't end for me, but doesn't seem related.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

test run fine with the change and fails without.

to be even more nit-picky: acquiring the application session and bailing out otherwise could be an extracted method.

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Looks good to me. New test is successful.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/scene/prompt_session_manager_impl.cpp'
2--- src/server/scene/prompt_session_manager_impl.cpp 2014-09-11 05:51:44 +0000
3+++ src/server/scene/prompt_session_manager_impl.cpp 2014-10-06 15:50:47 +0000
4@@ -109,6 +109,19 @@
5 PromptSessionCreationParameters const& params) const
6 {
7 auto prompt_session = std::make_shared<PromptSession>();
8+ std::shared_ptr<Session> application_session;
9+
10+ app_container->for_each(
11+ [&](std::shared_ptr<Session> const& session)
12+ {
13+ if (session->process_id() == params.application_pid)
14+ {
15+ application_session = session;
16+ }
17+ });
18+
19+ if (!application_session)
20+ BOOST_THROW_EXCEPTION(std::runtime_error("Could not identify application session"));
21
22 std::lock_guard<std::mutex> lock(prompt_sessions_mutex);
23
24@@ -119,14 +132,7 @@
25 session->start_prompt_session();
26 prompt_session_listener->starting(prompt_session);
27
28- app_container->for_each(
29- [&](std::shared_ptr<Session> const& session)
30- {
31- if (session->process_id() == params.application_pid)
32- {
33- prompt_session_container->insert_participant(prompt_session.get(), session, PromptSessionContainer::ParticipantType::application);
34- }
35- });
36+ prompt_session_container->insert_participant(prompt_session.get(), application_session, PromptSessionContainer::ParticipantType::application);
37
38 return prompt_session;
39 }
40
41=== modified file 'tests/acceptance-tests/test_prompt_session_client_api.cpp'
42--- tests/acceptance-tests/test_prompt_session_client_api.cpp 2014-09-30 06:11:33 +0000
43+++ tests/acceptance-tests/test_prompt_session_client_api.cpp 2014-10-06 15:50:47 +0000
44@@ -552,3 +552,20 @@
45
46 mir_prompt_session_release_sync(prompt_session);
47 }
48+
49+// lp:1377968
50+TEST_F(PromptSessionClientAPI, when_application_pid_is_invalid_starting_a_prompt_session_fails)
51+{
52+ connection = mir_connect_sync(new_prompt_connection().c_str(), __PRETTY_FUNCTION__);
53+
54+ EXPECT_CALL(*the_mock_prompt_session_listener(), starting(_)).Times(0);
55+
56+ MirPromptSession* prompt_session = mir_connection_create_prompt_session_sync(
57+ connection, ~application_session_pid, null_state_change_callback, this);
58+
59+ EXPECT_THAT(mir_prompt_session_is_valid(prompt_session), Eq(false));
60+ EXPECT_THAT(mir_prompt_session_error_message(prompt_session),
61+ HasSubstr("Could not identify application"));
62+
63+ mir_prompt_session_release_sync(prompt_session);
64+}
65
66=== modified file 'tests/integration-tests/frontend/test_session_mediator_report.cpp'
67--- tests/integration-tests/frontend/test_session_mediator_report.cpp 2014-09-24 03:38:59 +0000
68+++ tests/integration-tests/frontend/test_session_mediator_report.cpp 2014-10-06 15:50:47 +0000
69@@ -510,6 +510,8 @@
70
71 client.wait_for_connect_done();
72
73+ client.prompt_session_parameters.set_application_pid(getpid());
74+
75 client.display_server.start_prompt_session(
76 0,
77 &client.prompt_session_parameters,

Subscribers

People subscribed via source and target branches