Mir

Merge lp:~alan-griffiths/mir/socket-connection into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Robert Ancell
Approved revision: no longer in the source branch.
Merged at revision: 1087
Proposed branch: lp:~alan-griffiths/mir/socket-connection
Merge into: lp:mir
Diff against target: 1779 lines (+594/-283)
32 files modified
examples/basic_server.cpp (+39/-4)
examples/render_surfaces.cpp (+5/-4)
include/server/mir/default_server_configuration.h (+10/-3)
include/server/mir/frontend/connector.h (+14/-14)
include/server/mir/frontend/connector_report.h (+9/-9)
include/server/mir/frontend/session_creator.h (+44/-0)
include/server/mir/server_configuration.h (+2/-2)
include/test/mir_test/test_protobuf_server.h (+4/-4)
src/server/default_server_configuration.cpp (+2/-0)
src/server/display_server.cpp (+9/-9)
src/server/frontend/CMakeLists.txt (+6/-7)
src/server/frontend/default_configuration.cpp (+49/-21)
src/server/frontend/protobuf_session_creator.cpp (+73/-0)
src/server/frontend/protobuf_session_creator.h (+60/-0)
src/server/frontend/published_socket_connector.cpp (+79/-76)
src/server/frontend/published_socket_connector.h (+37/-38)
src/server/frontend/socket_messenger.cpp (+2/-1)
tests/acceptance-tests/test_client_library.cpp (+1/-1)
tests/acceptance-tests/test_server_shutdown.cpp (+3/-3)
tests/acceptance-tests/test_test_framework.cpp (+1/-1)
tests/integration-tests/client/test_client_render.cpp (+1/-1)
tests/integration-tests/shell/test_session.cpp (+5/-4)
tests/integration-tests/test_display_server_main_loop_events.cpp (+33/-32)
tests/integration-tests/test_error_reporting.cpp (+1/-1)
tests/mir_test_doubles/test_protobuf_socket_server.cpp (+10/-10)
tests/unit-tests/client/test_client_mir_surface.cpp (+1/-1)
tests/unit-tests/frontend/CMakeLists.txt (+1/-1)
tests/unit-tests/frontend/stress_protobuf_communicator.cpp (+1/-1)
tests/unit-tests/frontend/test_protobuf_reports_errors.cpp (+1/-1)
tests/unit-tests/frontend/test_protobuf_sends_fds.cpp (+1/-1)
tests/unit-tests/frontend/test_protobuf_surface_apis.cpp (+1/-1)
tests/unit-tests/frontend/test_published_socket_connector.cpp (+89/-32)
To merge this branch: bzr merge lp:~alan-griffiths/mir/socket-connection
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alexandros Frantzis (community) Approve
Review via email: mp+187326@code.launchpad.net

Commit message

frontend, config: Mechanism for connecting via a socket pair.

Description of the change

frontend, config: Mechanism for connecting via a socket pair.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

read through once, looks okay to me. want to look it over again, abstain for now

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Not a thorough review yet, but I like the new design separating the connection and session creation concerns.

A couple of nits I noticed:

952 +// Makes provides a client-side socket fd for each connection

1734 + EXPECT_CALL(*client, next_buffer_done()).Times(8);
1735 +
1736 + for (int i = 0; i != 8; ++i)

int const num_buffer_requests{8} ?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

Nits:

496 +char const* const no_server_socket_opt = "no-file";

Not used.

504 + return std::make_shared<mf::ProtobufSessionCreator>(
505 + the_ipc_factory(the_frontend_shell(),
506 + the_buffer_allocator()),

Current indentation makes the_buffer_allocator() seem like an argument of std::make_shared<mf::ProtobufSessionCreator>() instead of (the correct) the_ipc_factory().

review: Approve
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 :

FAILED: Autolanding.
Approved revid is not set in launchpad. This is most likely a launchpad issue and re-approve should fix it. There is also a chance (although a very small one) this is a permission problem of the ps-jenkins bot.
http://jenkins.qa.ubuntu.com/job/mir-team-mir-development-branch-autolanding/5/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-saucy-i386-build/2129
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-saucy-amd64-build/2014
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-team-mir-development-branch-saucy-amd64-autolanding/5
        deb: http://jenkins.qa.ubuntu.com/job/mir-team-mir-development-branch-saucy-amd64-autolanding/5/artifact/work/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

client_socket_fd()
the function looks like its making a new session, and creating an fd for a new client. The name could be create_fd_for_new_client()?

create_session_for()
are we creating a session for the socket? or creating a session with a socket? create_session_from_socket()

those are pretty minor naming issues though, lgtm

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/basic_server.cpp'
--- examples/basic_server.cpp 2013-08-29 03:48:16 +0000
+++ examples/basic_server.cpp 2013-09-25 14:20:36 +0000
@@ -16,18 +16,53 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */17 */
1818
19#include "server_configuration.h"
20
21#include "mir/abnormal_exit.h"
22#include "mir/frontend/connector.h"
23#include "mir/options/option.h"
24#include "mir/report_exception.h"
19#include "mir/run_mir.h"25#include "mir/run_mir.h"
20#include "mir/report_exception.h"
21#include "server_configuration.h"
2226
23#include <iostream>27#include <iostream>
2428
29namespace
30{
31char const* const launch_child_opt = "launch-client";
32
33struct ServerConfiguration : mir::examples::ServerConfiguration
34{
35 ServerConfiguration(int argc, char const** argv) :
36 mir::examples::ServerConfiguration(argc, argv)
37 {
38 namespace po = boost::program_options;
39
40 add_options()
41 (launch_child_opt, po::value<std::string>(), "system() command to launch client");
42 }
43
44 void launch_client()
45 {
46 if (the_options()->is_set(launch_child_opt))
47 {
48 char buffer[128] = {0};
49 sprintf(buffer, "fd://%d", the_connector()->client_socket_fd());
50 setenv("MIR_SOCKET", buffer, 1);
51 auto ignore = system((the_options()->get(launch_child_opt, "") + "&").c_str());
52 (void)ignore;
53 }
54 }
55
56 using mir::examples::ServerConfiguration::the_options;
57};
58}
59
25int main(int argc, char const* argv[])60int main(int argc, char const* argv[])
26try61try
27{62{
28 mir::examples::ServerConfiguration config(argc, argv);63 ServerConfiguration config(argc, argv);
2964
30 run_mir(config, [](mir::DisplayServer&) {/* empty init */});65 run_mir(config, [&](mir::DisplayServer&){ config.launch_client(); });
31 return 0;66 return 0;
32}67}
33catch (...)68catch (...)
3469
=== modified file 'examples/render_surfaces.cpp'
--- examples/render_surfaces.cpp 2013-09-19 13:24:22 +0000
+++ examples/render_surfaces.cpp 2013-09-25 14:20:36 +0000
@@ -19,7 +19,7 @@
19#include "mir/compositor/default_display_buffer_compositor_factory.h"19#include "mir/compositor/default_display_buffer_compositor_factory.h"
20#include "mir/compositor/display_buffer_compositor.h"20#include "mir/compositor/display_buffer_compositor.h"
21#include "mir/graphics/graphic_buffer_allocator.h"21#include "mir/graphics/graphic_buffer_allocator.h"
22#include "mir/frontend/communicator.h"22#include "mir/frontend/connector.h"
23#include "mir/shell/surface_creation_parameters.h"23#include "mir/shell/surface_creation_parameters.h"
24#include "mir/geometry/size.h"24#include "mir/geometry/size.h"
25#include "mir/geometry/rectangles.h"25#include "mir/geometry/rectangles.h"
@@ -266,15 +266,16 @@
266266
267 ///\internal [RenderSurfacesServerConfiguration_stubs_tag]267 ///\internal [RenderSurfacesServerConfiguration_stubs_tag]
268 // Stub out server connectivity.268 // Stub out server connectivity.
269 std::shared_ptr<mf::Communicator> the_communicator() override269 std::shared_ptr<mf::Connector> the_connector() override
270 {270 {
271 struct NullCommunicator : public mf::Communicator271 struct NullConnector : public mf::Connector
272 {272 {
273 void start() {}273 void start() {}
274 void stop() {}274 void stop() {}
275 int client_socket_fd() const override { return 0; }
275 };276 };
276277
277 return std::make_shared<NullCommunicator>();278 return std::make_shared<NullConnector>();
278 }279 }
279 ///\internal [RenderSurfacesServerConfiguration_stubs_tag]280 ///\internal [RenderSurfacesServerConfiguration_stubs_tag]
280281
281282
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2013-09-23 13:37:44 +0000
+++ include/server/mir/default_server_configuration.h 2013-09-25 14:20:36 +0000
@@ -41,8 +41,9 @@
41namespace frontend41namespace frontend
42{42{
43class Shell;43class Shell;
44class Communicator;44class Connector;
45class ProtobufIpcFactory;45class ProtobufIpcFactory;
46class SessionCreator;
46class SessionMediatorReport;47class SessionMediatorReport;
47class MessageProcessorReport;48class MessageProcessorReport;
48class SessionAuthorizer;49class SessionAuthorizer;
@@ -118,7 +119,7 @@
118 /** @name DisplayServer dependencies119 /** @name DisplayServer dependencies
119 * dependencies of DisplayServer on the rest of the Mir120 * dependencies of DisplayServer on the rest of the Mir
120 * @{ */121 * @{ */
121 virtual std::shared_ptr<frontend::Communicator> the_communicator();122 virtual std::shared_ptr<frontend::Connector> the_connector();
122 virtual std::shared_ptr<graphics::Display> the_display();123 virtual std::shared_ptr<graphics::Display> the_display();
123 virtual std::shared_ptr<compositor::Compositor> the_compositor();124 virtual std::shared_ptr<compositor::Compositor> the_compositor();
124 virtual std::shared_ptr<input::InputManager> the_input_manager();125 virtual std::shared_ptr<input::InputManager> the_input_manager();
@@ -168,6 +169,11 @@
168 virtual std::shared_ptr<frontend::Shell> the_frontend_shell();169 virtual std::shared_ptr<frontend::Shell> the_frontend_shell();
169 virtual std::shared_ptr<frontend::EventSink> the_global_event_sink();170 virtual std::shared_ptr<frontend::EventSink> the_global_event_sink();
170 virtual std::shared_ptr<frontend::DisplayChanger> the_frontend_display_changer();171 virtual std::shared_ptr<frontend::DisplayChanger> the_frontend_display_changer();
172 /** @name frontend configuration - internal dependencies
173 * internal dependencies of frontend
174 * @{ */
175 virtual std::shared_ptr<frontend::SessionCreator> the_session_creator();
176 /** @} */
171 /** @} */177 /** @} */
172178
173 virtual std::shared_ptr<shell::FocusController> the_focus_controller();179 virtual std::shared_ptr<shell::FocusController> the_focus_controller();
@@ -243,7 +249,7 @@
243 virtual std::shared_ptr<shell::MediatingDisplayChanger> the_mediating_display_changer();249 virtual std::shared_ptr<shell::MediatingDisplayChanger> the_mediating_display_changer();
244 virtual std::shared_ptr<shell::BroadcastingSessionEventSink> the_broadcasting_session_event_sink();250 virtual std::shared_ptr<shell::BroadcastingSessionEventSink> the_broadcasting_session_event_sink();
245251
246 CachedPtr<frontend::Communicator> communicator;252 CachedPtr<frontend::Connector> connector;
247 CachedPtr<shell::SessionManager> session_manager;253 CachedPtr<shell::SessionManager> session_manager;
248254
249255
@@ -266,6 +272,7 @@
266 CachedPtr<frontend::MessageProcessorReport> message_processor_report;272 CachedPtr<frontend::MessageProcessorReport> message_processor_report;
267 CachedPtr<frontend::SessionAuthorizer> session_authorizer;273 CachedPtr<frontend::SessionAuthorizer> session_authorizer;
268 CachedPtr<frontend::EventSink> global_event_sink;274 CachedPtr<frontend::EventSink> global_event_sink;
275 CachedPtr<frontend::SessionCreator> session_creator;
269 CachedPtr<compositor::RendererFactory> renderer_factory;276 CachedPtr<compositor::RendererFactory> renderer_factory;
270 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;277 CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory;
271 CachedPtr<surfaces::SurfaceStack> surface_stack;278 CachedPtr<surfaces::SurfaceStack> surface_stack;
272279
=== renamed file 'include/server/mir/frontend/communicator.h' => 'include/server/mir/frontend/connector.h'
--- include/server/mir/frontend/communicator.h 2013-04-25 09:48:54 +0000
+++ include/server/mir/frontend/connector.h 2013-09-25 14:20:36 +0000
@@ -16,29 +16,29 @@
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 */17 */
1818
19#ifndef MIR_FRONTEND_COMMUNICATOR_H_19#ifndef MIR_FRONTEND_CONNECTOR_H_
20#define MIR_FRONTEND_COMMUNICATOR_H_20#define MIR_FRONTEND_CONNECTOR_H_
2121
22namespace mir22namespace mir
23{23{
24namespace frontend24namespace frontend
25{25{
2626/// Handle client process connections
27class Communicator27class Connector
28{28{
29public:29public:
30 virtual ~Communicator() {}
31
32 virtual void start() = 0;30 virtual void start() = 0;
33 virtual void stop() = 0;31 virtual void stop() = 0;
3432
33 virtual int client_socket_fd() const = 0;
34
35protected:35protected:
36 Communicator() = default;36 Connector() = default;
37 Communicator(const Communicator&) = delete;37 virtual ~Connector() = default;
38 Communicator& operator=(const Communicator&) = delete;38 Connector(const Connector&) = delete;
39 Connector& operator=(const Connector&) = delete;
39};40};
4041}
41}42}
42}43
4344#endif // MIR_FRONTEND_CONNECTOR_H_
44#endif // MIR_FRONTEND_COMMUNICATOR_H_
4545
=== renamed file 'include/server/mir/frontend/communicator_report.h' => 'include/server/mir/frontend/connector_report.h'
--- include/server/mir/frontend/communicator_report.h 2013-06-19 16:14:40 +0000
+++ include/server/mir/frontend/connector_report.h 2013-09-25 14:20:36 +0000
@@ -16,8 +16,8 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk16 * Authored by: Alan Griffiths <alan@octopull.co.uk
17 */17 */
1818
19#ifndef MIR_FRONTEND_COMMUNICATOR_REPORT_H_19#ifndef MIR_FRONTEND_CONNECTOR_REPORT_H_
20#define MIR_FRONTEND_COMMUNICATOR_REPORT_H_20#define MIR_FRONTEND_CONNECTOR_REPORT_H_
2121
22#include <stdexcept>22#include <stdexcept>
2323
@@ -26,20 +26,20 @@
26namespace frontend26namespace frontend
27{27{
2828
29class CommunicatorReport29class ConnectorReport
30{30{
31public:31public:
3232
33 virtual void error(std::exception const& error) = 0;33 virtual void error(std::exception const& error) = 0;
3434
35protected:35protected:
36 virtual ~CommunicatorReport() = default;36 virtual ~ConnectorReport() = default;
37 CommunicatorReport() = default;37 ConnectorReport() = default;
38 CommunicatorReport(const CommunicatorReport&) = delete;38 ConnectorReport(const ConnectorReport&) = delete;
39 CommunicatorReport& operator=(const CommunicatorReport&) = delete;39 ConnectorReport& operator=(const ConnectorReport&) = delete;
40};40};
4141
42class NullCommunicatorReport : public CommunicatorReport42class NullConnectorReport : public ConnectorReport
43{43{
44public:44public:
4545
@@ -48,4 +48,4 @@
48}48}
49}49}
5050
51#endif // MIR_FRONTEND_COMMUNICATOR_REPORT_H_51#endif // MIR_FRONTEND_CONNECTOR_REPORT_H_
5252
=== added file 'include/server/mir/frontend/session_creator.h'
--- include/server/mir/frontend/session_creator.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/frontend/session_creator.h 2013-09-25 14:20:36 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_FRONTEND_SESSION_CREATOR_H_
20#define MIR_FRONTEND_SESSION_CREATOR_H_
21
22#include <boost/asio.hpp>
23
24#include <memory>
25
26namespace mir
27{
28namespace frontend
29{
30class SessionCreator
31{
32public:
33 virtual void create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket) = 0;
34
35protected:
36 SessionCreator() = default;
37 virtual ~SessionCreator() noexcept = default;
38 SessionCreator(SessionCreator const&) = delete;
39 SessionCreator& operator=(SessionCreator const&) = delete;
40};
41}
42}
43
44#endif /* MIR_FRONTEND_SESSION_CREATOR_H_ */
045
=== modified file 'include/server/mir/server_configuration.h'
--- include/server/mir/server_configuration.h 2013-09-18 21:09:29 +0000
+++ include/server/mir/server_configuration.h 2013-09-25 14:20:36 +0000
@@ -28,7 +28,7 @@
28}28}
29namespace frontend29namespace frontend
30{30{
31class Communicator;31class Connector;
32class Shell;32class Shell;
33}33}
34namespace shell34namespace shell
@@ -57,7 +57,7 @@
57public:57public:
58 // TODO most of these interfaces are wider DisplayServer needs...58 // TODO most of these interfaces are wider DisplayServer needs...
59 // TODO ...some or all of them need narrowing59 // TODO ...some or all of them need narrowing
60 virtual std::shared_ptr<frontend::Communicator> the_communicator() = 0;60 virtual std::shared_ptr<frontend::Connector> the_connector() = 0;
61 virtual std::shared_ptr<graphics::Display> the_display() = 0;61 virtual std::shared_ptr<graphics::Display> the_display() = 0;
62 virtual std::shared_ptr<compositor::Compositor> the_compositor() = 0;62 virtual std::shared_ptr<compositor::Compositor> the_compositor() = 0;
63 virtual std::shared_ptr<input::InputManager> the_input_manager() = 0;63 virtual std::shared_ptr<input::InputManager> the_input_manager() = 0;
6464
=== modified file 'include/test/mir_test/test_protobuf_server.h'
--- include/test/mir_test/test_protobuf_server.h 2013-06-19 16:14:40 +0000
+++ include/test/mir_test/test_protobuf_server.h 2013-09-25 14:20:36 +0000
@@ -25,8 +25,8 @@
25{25{
26namespace frontend26namespace frontend
27{27{
28class Communicator;28class Connector;
29class CommunicatorReport;29class ConnectorReport;
30}30}
3131
32namespace protobuf32namespace protobuf
@@ -45,10 +45,10 @@
45 TestProtobufServer(45 TestProtobufServer(
46 std::string const& socket_name,46 std::string const& socket_name,
47 std::shared_ptr<protobuf::DisplayServer> const& tool,47 std::shared_ptr<protobuf::DisplayServer> const& tool,
48 std::shared_ptr<frontend::CommunicatorReport> const& report);48 std::shared_ptr<frontend::ConnectorReport> const& report);
4949
50 // "Server" side50 // "Server" side
51 std::shared_ptr<frontend::Communicator> const comm;51 std::shared_ptr<frontend::Connector> const comm;
52};52};
53}53}
54}54}
5555
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2013-09-23 13:37:44 +0000
+++ src/server/default_server_configuration.cpp 2013-09-25 14:20:36 +0000
@@ -171,6 +171,7 @@
171};171};
172172
173char const* const server_socket_opt = "file";173char const* const server_socket_opt = "file";
174char const* const no_server_socket_opt = "no-file";
174char const* const session_mediator_report_opt = "session-mediator-report";175char const* const session_mediator_report_opt = "session-mediator-report";
175char const* const msg_processor_report_opt = "msg-processor-report";176char const* const msg_processor_report_opt = "msg-processor-report";
176char const* const display_report_opt = "display-report";177char const* const display_report_opt = "display-report";
@@ -255,6 +256,7 @@
255 "Host socket filename. [string:default={$MIR_SOCKET,/tmp/mir_socket}]")256 "Host socket filename. [string:default={$MIR_SOCKET,/tmp/mir_socket}]")
256 ("file,f", po::value<std::string>(),257 ("file,f", po::value<std::string>(),
257 "Socket filename. [string:default=/tmp/mir_socket]")258 "Socket filename. [string:default=/tmp/mir_socket]")
259 (no_server_socket_opt, "Do not provide a socket filename for client connections")
258 (platform_graphics_lib, po::value<std::string>(),260 (platform_graphics_lib, po::value<std::string>(),
259 "Library to use for platform graphics support [default=libmirplatformgraphics.so]")261 "Library to use for platform graphics support [default=libmirplatformgraphics.so]")
260 ("enable-input,i", po::value<bool>(),262 ("enable-input,i", po::value<bool>(),
261263
=== modified file 'src/server/display_server.cpp'
--- src/server/display_server.cpp 2013-09-18 21:09:29 +0000
+++ src/server/display_server.cpp 2013-09-25 14:20:36 +0000
@@ -25,7 +25,7 @@
25#include "mir/display_changer.h"25#include "mir/display_changer.h"
2626
27#include "mir/compositor/compositor.h"27#include "mir/compositor/compositor.h"
28#include "mir/frontend/communicator.h"28#include "mir/frontend/connector.h"
29#include "mir/graphics/display.h"29#include "mir/graphics/display.h"
30#include "mir/input/input_manager.h"30#include "mir/input/input_manager.h"
3131
@@ -72,7 +72,7 @@
72 display{config.the_display()},72 display{config.the_display()},
73 input_configuration{config.the_input_configuration()},73 input_configuration{config.the_input_configuration()},
74 compositor{config.the_compositor()},74 compositor{config.the_compositor()},
75 communicator{config.the_communicator()},75 connector{config.the_connector()},
76 input_manager{config.the_input_manager()},76 input_manager{config.the_input_manager()},
77 main_loop{config.the_main_loop()},77 main_loop{config.the_main_loop()},
78 pause_resume_listener{config.the_pause_resume_listener()},78 pause_resume_listener{config.the_pause_resume_listener()},
@@ -103,8 +103,8 @@
103 [this] { compositor->start(); }};103 [this] { compositor->start(); }};
104104
105 TryButRevertIfUnwinding comm{105 TryButRevertIfUnwinding comm{
106 [this] { communicator->stop(); },106 [this] { connector->stop(); },
107 [this] { communicator->start(); }};107 [this] { connector->start(); }};
108108
109 display->pause();109 display->pause();
110110
@@ -129,8 +129,8 @@
129 [this] { display->pause(); }};129 [this] { display->pause(); }};
130130
131 TryButRevertIfUnwinding comm{131 TryButRevertIfUnwinding comm{
132 [this] { communicator->start(); },132 [this] { connector->start(); },
133 [this] { communicator->stop(); }};133 [this] { connector->stop(); }};
134134
135 if (configure_display_on_resume)135 if (configure_display_on_resume)
136 {136 {
@@ -176,7 +176,7 @@
176 std::shared_ptr<mg::Display> const display;176 std::shared_ptr<mg::Display> const display;
177 std::shared_ptr<input::InputConfiguration> const input_configuration;177 std::shared_ptr<input::InputConfiguration> const input_configuration;
178 std::shared_ptr<mc::Compositor> const compositor;178 std::shared_ptr<mc::Compositor> const compositor;
179 std::shared_ptr<mf::Communicator> const communicator;179 std::shared_ptr<mf::Connector> const connector;
180 std::shared_ptr<mi::InputManager> const input_manager;180 std::shared_ptr<mi::InputManager> const input_manager;
181 std::shared_ptr<mir::MainLoop> const main_loop;181 std::shared_ptr<mir::MainLoop> const main_loop;
182 std::shared_ptr<mir::PauseResumeListener> const pause_resume_listener;182 std::shared_ptr<mir::PauseResumeListener> const pause_resume_listener;
@@ -201,7 +201,7 @@
201201
202void mir::DisplayServer::run()202void mir::DisplayServer::run()
203{203{
204 p->communicator->start();204 p->connector->start();
205 p->compositor->start();205 p->compositor->start();
206 p->input_manager->start();206 p->input_manager->start();
207207
@@ -209,7 +209,7 @@
209209
210 p->input_manager->stop();210 p->input_manager->stop();
211 p->compositor->stop();211 p->compositor->stop();
212 p->communicator->stop();212 p->connector->stop();
213}213}
214214
215void mir::DisplayServer::stop()215void mir::DisplayServer::stop()
216216
=== modified file 'src/server/frontend/CMakeLists.txt'
--- src/server/frontend/CMakeLists.txt 2013-08-28 03:41:48 +0000
+++ src/server/frontend/CMakeLists.txt 2013-09-25 14:20:36 +0000
@@ -9,20 +9,19 @@
9 protobuf_buffer_packer.cpp9 protobuf_buffer_packer.cpp
10 null_message_processor.cpp10 null_message_processor.cpp
11 global_event_sender.cpp11 global_event_sender.cpp
1212 published_socket_connector.cpp
13 protobuf_session_creator.cpp
14 socket_session.cpp
13 resource_cache.cpp15 resource_cache.cpp
14 socket_messenger.cpp16 socket_messenger.cpp
15 event_sender.cpp17 event_sender.cpp
16 surface.cpp18 surface.cpp
19
20 default_configuration.cpp
21
17 ${PROTO_HDRS}22 ${PROTO_HDRS}
18)23)
1924
20list(APPEND FRONTEND_SOURCES
21 protobuf_socket_communicator.cpp
22 make_protobuf_socket_communicator.cpp
23 socket_session.cpp
24)
25
26if (MIR_PLATFORM STREQUAL "android")25if (MIR_PLATFORM STREQUAL "android")
27 list(APPEND FRONTEND_SOURCES session_mediator_android.cpp)26 list(APPEND FRONTEND_SOURCES session_mediator_android.cpp)
28elseif (MIR_PLATFORM STREQUAL "gbm")27elseif (MIR_PLATFORM STREQUAL "gbm")
2928
=== renamed file 'src/server/frontend/make_protobuf_socket_communicator.cpp' => 'src/server/frontend/default_configuration.cpp'
--- src/server/frontend/make_protobuf_socket_communicator.cpp 2013-08-28 03:41:48 +0000
+++ src/server/frontend/default_configuration.cpp 2013-09-25 14:20:36 +0000
@@ -17,39 +17,67 @@
17 */17 */
1818
19#include "mir/default_server_configuration.h"19#include "mir/default_server_configuration.h"
20#include "protobuf_session_creator.h"
21
20#include "mir/options/option.h"22#include "mir/options/option.h"
21#include "mir/frontend/shell.h"23#include "mir/frontend/shell.h"
22#include "mir/shell/session_container.h"24#include "mir/shell/session_container.h"
23#include "mir/shell/session.h"25#include "mir/shell/session.h"
24#include "protobuf_socket_communicator.h"26#include "published_socket_connector.h"
25#include "mir/frontend/communicator_report.h"27#include "mir/frontend/connector_report.h"
2628
27namespace mf = mir::frontend;29namespace mf = mir::frontend;
28namespace mg = mir::graphics;
29namespace mc = mir::compositor;
30namespace msh = mir::shell;30namespace msh = mir::shell;
3131
32std::shared_ptr<mf::Communicator>32namespace
33mir::DefaultServerConfiguration::the_communicator()33{
34{34char const* const no_server_socket_opt = "no-file";
35 return communicator(35}
36 [&,this]() -> std::shared_ptr<mf::Communicator>36
37std::shared_ptr<mf::SessionCreator>
38mir::DefaultServerConfiguration::the_session_creator()
39{
40 return session_creator([this]
41 {
42 return std::make_shared<mf::ProtobufSessionCreator>(
43 the_ipc_factory(the_frontend_shell(), the_buffer_allocator()),
44 the_session_authorizer());
45 });
46}
47
48std::shared_ptr<mf::Connector>
49mir::DefaultServerConfiguration::the_connector()
50{
51 return connector(
52 [&,this]() -> std::shared_ptr<mf::Connector>
37 {53 {
38 auto const threads = the_options()->get("ipc-thread-pool", 10);54 auto const threads = the_options()->get("ipc-thread-pool", 10);
39 auto shell_sessions = the_shell_session_container();55 auto shell_sessions = the_shell_session_container();
40 return std::make_shared<mf::ProtobufSocketCommunicator>(56 auto const& force_requests_to_complete = [shell_sessions]
41 the_socket_file(),57 {
42 the_ipc_factory(the_frontend_shell(), the_buffer_allocator()),58 shell_sessions->for_each([](std::shared_ptr<msh::Session> const& session)
43 the_session_authorizer(),
44 threads,
45 [shell_sessions]
46 {59 {
47 shell_sessions->for_each([](std::shared_ptr<msh::Session> const& session)60 session->force_requests_to_complete();
48 {61 });
49 session->force_requests_to_complete();62 };
50 });63
51 },64 if (the_options()->is_set(no_server_socket_opt))
52 std::make_shared<mf::NullCommunicatorReport>());65 {
66 return std::make_shared<mf::BasicConnector>(
67 the_session_creator(),
68 threads,
69 force_requests_to_complete,
70 std::make_shared<mf::NullConnectorReport>());
71 }
72 else
73 {
74 return std::make_shared<mf::PublishedSocketConnector>(
75 the_socket_file(),
76 the_session_creator(),
77 threads,
78 force_requests_to_complete,
79 std::make_shared<mf::NullConnectorReport>());
80 }
53 });81 });
54}82}
5583
5684
=== added file 'src/server/frontend/protobuf_session_creator.cpp'
--- src/server/frontend/protobuf_session_creator.cpp 1970-01-01 00:00:00 +0000
+++ src/server/frontend/protobuf_session_creator.cpp 2013-09-25 14:20:36 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "protobuf_session_creator.h"
20
21#include "event_sender.h"
22#include "protobuf_message_processor.h"
23#include "socket_messenger.h"
24#include "socket_session.h"
25
26#include "mir/frontend/protobuf_ipc_factory.h"
27#include "mir/frontend/session_authorizer.h"
28#include "mir/protobuf/google_protobuf_guard.h"
29
30namespace mf = mir::frontend;
31namespace mfd = mir::frontend::detail;
32namespace ba = boost::asio;
33
34mf::ProtobufSessionCreator::ProtobufSessionCreator(
35 std::shared_ptr<ProtobufIpcFactory> const& ipc_factory,
36 std::shared_ptr<mf::SessionAuthorizer> const& session_authorizer)
37: ipc_factory(ipc_factory),
38 session_authorizer(session_authorizer),
39 next_session_id(0),
40 connected_sessions(std::make_shared<mfd::ConnectedSessions<mfd::SocketSession>>())
41{
42}
43
44mf::ProtobufSessionCreator::~ProtobufSessionCreator() noexcept
45{
46 connected_sessions->clear();
47}
48
49int mf::ProtobufSessionCreator::next_id()
50{
51 return next_session_id.fetch_add(1);
52}
53
54void mf::ProtobufSessionCreator::create_session_for(std::shared_ptr<ba::local::stream_protocol::socket> const& socket)
55{
56 auto const messenger = std::make_shared<detail::SocketMessenger>(socket);
57 auto const client_pid = messenger->client_pid();
58
59 if (session_authorizer->connection_is_allowed(client_pid))
60 {
61 auto const authorized_to_resize_display = session_authorizer->configure_display_is_allowed(client_pid);
62 auto const event_sink = std::make_shared<detail::EventSender>(messenger);
63 auto const msg_processor = std::make_shared<detail::ProtobufMessageProcessor>(
64 messenger,
65 ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display),
66 ipc_factory->resource_cache(),
67 ipc_factory->report());
68
69 const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor);
70 connected_sessions->add(session);
71 session->read_next_message();
72 }
73}
074
=== added file 'src/server/frontend/protobuf_session_creator.h'
--- src/server/frontend/protobuf_session_creator.h 1970-01-01 00:00:00 +0000
+++ src/server/frontend/protobuf_session_creator.h 2013-09-25 14:20:36 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_FRONTEND_PROTOBUF_SESSION_CREATOR_H_
20#define MIR_FRONTEND_PROTOBUF_SESSION_CREATOR_H_
21
22#include "mir/frontend/session_creator.h"
23#include "connected_sessions.h"
24
25#include <atomic>
26
27namespace mir
28{
29namespace frontend
30{
31class ProtobufIpcFactory;
32class SessionAuthorizer;
33
34namespace detail
35{
36struct SocketSession;
37}
38
39class ProtobufSessionCreator : public SessionCreator
40{
41public:
42 ProtobufSessionCreator(
43 std::shared_ptr<ProtobufIpcFactory> const& ipc_factory,
44 std::shared_ptr<SessionAuthorizer> const& session_authorizer);
45 ~ProtobufSessionCreator() noexcept;
46
47 void create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket);
48
49private:
50 int next_id();
51
52 std::shared_ptr<ProtobufIpcFactory> const ipc_factory;
53 std::shared_ptr<SessionAuthorizer> const session_authorizer;
54 std::atomic<int> next_session_id;
55 std::shared_ptr<detail::ConnectedSessions<detail::SocketSession>> const connected_sessions;
56};
57}
58}
59
60#endif /* MIR_FRONTEND_PROTOBUF_SESSION_CREATOR_H_ */
061
=== renamed file 'src/server/frontend/protobuf_socket_communicator.cpp' => 'src/server/frontend/published_socket_connector.cpp'
--- src/server/frontend/protobuf_socket_communicator.cpp 2013-08-28 03:41:48 +0000
+++ src/server/frontend/published_socket_connector.cpp 2013-09-25 14:20:36 +0000
@@ -16,67 +16,78 @@
16 * Authored by: Thomas Guest <thomas.guest@canonical.com>16 * Authored by: Thomas Guest <thomas.guest@canonical.com>
17 */17 */
1818
19#include "protobuf_socket_communicator.h"19#include "published_socket_connector.h"
20#include "protobuf_message_processor.h"20#include "protobuf_session_creator.h"
21#include "socket_session.h"
2221
23#include "mir/frontend/communicator_report.h"22#include "mir/frontend/connector_report.h"
24#include "mir/frontend/protobuf_ipc_factory.h"
25#include "mir/frontend/session_authorizer.h"
26#include "socket_messenger.h"
27#include "event_sender.h"
28#include "mir/protobuf/google_protobuf_guard.h"
2923
30#include <boost/signals2.hpp>24#include <boost/signals2.hpp>
25#include <boost/exception/errinfo_errno.hpp>
26#include <boost/throw_exception.hpp>
27
28#include <sys/socket.h>
3129
32namespace mf = mir::frontend;30namespace mf = mir::frontend;
33namespace mfd = mir::frontend::detail;31namespace mfd = mir::frontend::detail;
34namespace ba = boost::asio;32namespace ba = boost::asio;
3533
36mf::ProtobufSocketCommunicator::ProtobufSocketCommunicator(34mf::PublishedSocketConnector::PublishedSocketConnector(
37 std::string const& socket_file,35 const std::string& socket_file,
38 std::shared_ptr<ProtobufIpcFactory> const& ipc_factory,36 std::shared_ptr<SessionCreator> const& session_creator,
39 std::shared_ptr<mf::SessionAuthorizer> const& session_authorizer,
40 int threads,37 int threads,
41 std::function<void()> const& force_requests_to_complete,38 std::function<void()> const& force_requests_to_complete,
42 std::shared_ptr<CommunicatorReport> const& report)39 std::shared_ptr<ConnectorReport> const& report)
43: socket_file((std::remove(socket_file.c_str()), socket_file)),40: BasicConnector(session_creator, threads, force_requests_to_complete, report),
44 acceptor(io_service, socket_file),41 socket_file(socket_file),
45 io_service_threads(threads),42 acceptor(io_service, socket_file)
46 ipc_factory(ipc_factory),
47 session_authorizer(session_authorizer),
48 next_session_id(0),
49 connected_sessions(std::make_shared<mfd::ConnectedSessions<mfd::SocketSession>>()),
50 force_requests_to_complete(force_requests_to_complete),
51 report(report)
52{43{
53 start_accept();44 start_accept();
54}45}
5546
56void mf::ProtobufSocketCommunicator::start_accept()47mf::PublishedSocketConnector::~PublishedSocketConnector() noexcept
48{
49 std::remove(socket_file.c_str());
50}
51
52void mf::PublishedSocketConnector::start_accept()
57{53{
58 auto socket = std::make_shared<boost::asio::local::stream_protocol::socket>(io_service);54 auto socket = std::make_shared<boost::asio::local::stream_protocol::socket>(io_service);
5955
60 acceptor.async_accept(56 acceptor.async_accept(
61 *socket,57 *socket,
62 boost::bind(58 boost::bind(
63 &ProtobufSocketCommunicator::on_new_connection,59 &PublishedSocketConnector::on_new_connection,
64 this,60 this,
65 socket,61 socket,
66 ba::placeholders::error));62 ba::placeholders::error));
67}63}
6864
69int mf::ProtobufSocketCommunicator::next_id()65void mf::PublishedSocketConnector::on_new_connection(
70{66 std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket,
71 int id = next_session_id.load();67 boost::system::error_code const& ec)
72 while (!next_session_id.compare_exchange_weak(id, id + 1)) std::this_thread::yield();68{
73 return id;69 if (!ec)
74}70 {
7571 create_session_for(socket);
7672 }
77void mf::ProtobufSocketCommunicator::start()73 start_accept();
78{74}
79 auto run_io_service = [&]75
76mf::BasicConnector::BasicConnector(
77 std::shared_ptr<SessionCreator> const& session_creator,
78 int threads,
79 std::function<void()> const& force_requests_to_complete,
80 std::shared_ptr<ConnectorReport> const& report)
81: io_service_threads(threads),
82 force_requests_to_complete(force_requests_to_complete),
83 report(report),
84 session_creator{session_creator}
85{
86}
87
88void mf::BasicConnector::start()
89{
90 auto run_io_service = [this]
80 {91 {
81 while (true)92 while (true)
82 try93 try
@@ -92,16 +103,16 @@
92103
93 for (auto& thread : io_service_threads)104 for (auto& thread : io_service_threads)
94 {105 {
95 thread = std::move(std::thread(run_io_service));106 thread = std::thread(run_io_service);
96 }107 }
97}108}
98109
99void mf::ProtobufSocketCommunicator::stop()110void mf::BasicConnector::stop()
100{111{
101 /* Stop processing new requests */112 /* Stop processing new requests */
102 io_service.stop();113 io_service.stop();
103114
104 /* 115 /*
105 * Ensure that any pending requests will complete (i.e., that they116 * Ensure that any pending requests will complete (i.e., that they
106 * will not block indefinitely waiting for a resource from the server)117 * will not block indefinitely waiting for a resource from the server)
107 */118 */
@@ -120,44 +131,36 @@
120 io_service.reset();131 io_service.reset();
121}132}
122133
123mf::ProtobufSocketCommunicator::~ProtobufSocketCommunicator()134void mf::BasicConnector::create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& server_socket) const
135{
136 session_creator->create_session_for(server_socket);
137}
138
139int mf::BasicConnector::client_socket_fd() const
140{
141 enum { server, client, size };
142 int socket_fd[size];
143
144 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fd))
145 {
146 BOOST_THROW_EXCEPTION(
147 boost::enable_error_info(
148 std::runtime_error("Could not create socket pair")) << boost::errinfo_errno(errno));
149 }
150
151 auto const server_socket = std::make_shared<boost::asio::local::stream_protocol::socket>(
152 io_service, boost::asio::local::stream_protocol(), socket_fd[server]);
153
154 create_session_for(server_socket);
155
156 return socket_fd[client];
157}
158
159mf::BasicConnector::~BasicConnector() noexcept
124{160{
125 stop();161 stop();
126162}
127 connected_sessions->clear();163
128164void mf::NullConnectorReport::error(std::exception const& /*error*/)
129 std::remove(socket_file.c_str());
130}
131
132void mf::ProtobufSocketCommunicator::on_new_connection(
133 std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket,
134 boost::system::error_code const& ec)
135{
136 if (!ec)
137 {
138 auto messenger = std::make_shared<detail::SocketMessenger>(socket);
139 auto client_pid = messenger->client_pid();
140 if (session_authorizer->connection_is_allowed(client_pid))
141 {
142 auto authorized_to_resize_display = session_authorizer->configure_display_is_allowed(client_pid);
143 auto event_sink = std::make_shared<detail::EventSender>(messenger);
144 auto msg_processor = std::make_shared<detail::ProtobufMessageProcessor>(
145 messenger,
146 ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display),
147 ipc_factory->resource_cache(),
148 ipc_factory->report());
149 auto const& session = std::make_shared<mfd::SocketSession>(
150 messenger,
151 next_id(),
152 connected_sessions,
153 msg_processor);
154 connected_sessions->add(session);
155 session->read_next_message();
156 }
157 }
158 start_accept();
159}
160
161void mf::NullCommunicatorReport::error(std::exception const& /*error*/)
162{165{
163}166}
164167
=== renamed file 'src/server/frontend/protobuf_socket_communicator.h' => 'src/server/frontend/published_socket_connector.h'
--- src/server/frontend/protobuf_socket_communicator.h 2013-08-28 03:41:48 +0000
+++ src/server/frontend/published_socket_connector.h 2013-09-25 14:20:36 +0000
@@ -19,13 +19,10 @@
19#ifndef MIR_FRONTEND_PROTOBUF_ASIO_COMMUNICATOR_H_19#ifndef MIR_FRONTEND_PROTOBUF_ASIO_COMMUNICATOR_H_
20#define MIR_FRONTEND_PROTOBUF_ASIO_COMMUNICATOR_H_20#define MIR_FRONTEND_PROTOBUF_ASIO_COMMUNICATOR_H_
2121
22#include "connected_sessions.h"22#include "mir/frontend/connector.h"
23
24#include "mir/frontend/communicator.h"
2523
26#include <boost/asio.hpp>24#include <boost/asio.hpp>
2725
28#include <atomic>
29#include <thread>26#include <thread>
30#include <string>27#include <string>
31#include <vector>28#include <vector>
@@ -43,52 +40,54 @@
43{40{
44namespace frontend41namespace frontend
45{42{
46class ResourceCache;43class SessionCreator;
47class ProtobufIpcFactory;44class ConnectorReport;
48class SessionAuthorizer;45
4946/// provides a client-side socket fd for each connection
50namespace detail47class BasicConnector : public Connector
51{48{
52struct SocketSession;49public:
53class MessageSender;50 explicit BasicConnector(
54}51 std::shared_ptr<SessionCreator> const& session_creator,
5552 int threads,
56class CommunicatorReport;53 std::function<void()> const& force_requests_to_complete,
5754 std::shared_ptr<ConnectorReport> const& report);
58class ProtobufSocketCommunicator : public Communicator55 ~BasicConnector() noexcept;
59{56 void start() override;
60public:57 void stop() override;
61 // Create communicator based on Boost asio and Google protobufs58 int client_socket_fd() const override;
62 // using the supplied socket.59
63 explicit ProtobufSocketCommunicator(60protected:
61 void create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& server_socket) const;
62 boost::asio::io_service mutable io_service;
63
64private:
65 std::vector<std::thread> io_service_threads;
66 std::function<void()> const force_requests_to_complete;
67 std::shared_ptr<ConnectorReport> const report;
68 std::shared_ptr<SessionCreator> const session_creator;
69};
70
71/// Accept connections over a published socket
72class PublishedSocketConnector : public BasicConnector
73{
74public:
75 explicit PublishedSocketConnector(
64 const std::string& socket_file,76 const std::string& socket_file,
65 std::shared_ptr<ProtobufIpcFactory> const& ipc_factory,77 std::shared_ptr<SessionCreator> const& session_creator,
66 std::shared_ptr<SessionAuthorizer> const& session_authorizer,
67 int threads,78 int threads,
68 std::function<void()> const& force_requests_to_complete,79 std::function<void()> const& force_requests_to_complete,
69 std::shared_ptr<CommunicatorReport> const& report);80 std::shared_ptr<ConnectorReport> const& report);
70 ~ProtobufSocketCommunicator();81 ~PublishedSocketConnector() noexcept;
71 void start();
72 void stop();
7382
74private:83private:
75 void start_accept();84 void start_accept();
76 void on_new_connection(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket,85 void on_new_connection(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket,
77 boost::system::error_code const& ec);86 boost::system::error_code const& ec);
78 int next_id();
7987
80 const std::string socket_file;88 const std::string socket_file;
81 boost::asio::io_service io_service;
82 boost::asio::local::stream_protocol::acceptor acceptor;89 boost::asio::local::stream_protocol::acceptor acceptor;
83 std::vector<std::thread> io_service_threads;
84 std::shared_ptr<ProtobufIpcFactory> const ipc_factory;
85 std::shared_ptr<SessionAuthorizer> const session_authorizer;
86 std::atomic<int> next_session_id;
87 std::shared_ptr<detail::ConnectedSessions<detail::SocketSession>> const connected_sessions;
88 std::function<void()> const force_requests_to_complete;
89 std::shared_ptr<CommunicatorReport> const report;
90};90};
91
92}91}
93}92}
9493
9594
=== modified file 'src/server/frontend/socket_messenger.cpp'
--- src/server/frontend/socket_messenger.cpp 2013-08-28 03:41:48 +0000
+++ src/server/frontend/socket_messenger.cpp 2013-09-25 14:20:36 +0000
@@ -59,7 +59,8 @@
59 // function has completed (if it would be executed asynchronously.59 // function has completed (if it would be executed asynchronously.
60 // NOTE: we rely on this synchronous behavior as per the comment in60 // NOTE: we rely on this synchronous behavior as per the comment in
61 // mf::SessionMediator::create_surface61 // mf::SessionMediator::create_surface
62 ba::write(*socket, ba::buffer(whole_message));62 boost::system::error_code err;
63 ba::write(*socket, ba::buffer(whole_message), err);
63}64}
6465
65void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds)66void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds)
6667
=== modified file 'tests/acceptance-tests/test_client_library.cpp'
--- tests/acceptance-tests/test_client_library.cpp 2013-09-17 14:31:42 +0000
+++ tests/acceptance-tests/test_client_library.cpp 2013-09-25 14:20:36 +0000
@@ -22,7 +22,7 @@
22#include "mir_toolkit/mir_client_library_debug.h"22#include "mir_toolkit/mir_client_library_debug.h"
23#include "src/client/client_buffer.h"23#include "src/client/client_buffer.h"
2424
25#include "mir/frontend/communicator.h"25#include "mir/frontend/connector.h"
2626
27#include "mir_protobuf.pb.h"27#include "mir_protobuf.pb.h"
2828
2929
=== modified file 'tests/acceptance-tests/test_server_shutdown.cpp'
--- tests/acceptance-tests/test_server_shutdown.cpp 2013-09-17 14:31:42 +0000
+++ tests/acceptance-tests/test_server_shutdown.cpp 2013-09-25 14:20:36 +0000
@@ -326,19 +326,19 @@
326 */326 */
327 std::weak_ptr<mir::graphics::Display> display = server_config->the_display();327 std::weak_ptr<mir::graphics::Display> display = server_config->the_display();
328 std::weak_ptr<mir::compositor::Compositor> compositor = server_config->the_compositor();328 std::weak_ptr<mir::compositor::Compositor> compositor = server_config->the_compositor();
329 std::weak_ptr<mir::frontend::Communicator> communicator = server_config->the_communicator();329 std::weak_ptr<mir::frontend::Connector> connector = server_config->the_connector();
330 std::weak_ptr<mir::input::InputManager> input_manager = server_config->the_input_manager();330 std::weak_ptr<mir::input::InputManager> input_manager = server_config->the_input_manager();
331331
332 server_config.reset();332 server_config.reset();
333333
334 EXPECT_EQ(0, display.use_count());334 EXPECT_EQ(0, display.use_count());
335 EXPECT_EQ(0, compositor.use_count());335 EXPECT_EQ(0, compositor.use_count());
336 EXPECT_EQ(0, communicator.use_count());336 EXPECT_EQ(0, connector.use_count());
337 EXPECT_EQ(0, input_manager.use_count());337 EXPECT_EQ(0, input_manager.use_count());
338338
339 if (display.use_count() != 0 ||339 if (display.use_count() != 0 ||
340 compositor.use_count() != 0 ||340 compositor.use_count() != 0 ||
341 communicator.use_count() != 0 ||341 connector.use_count() != 0 ||
342 input_manager.use_count() != 0)342 input_manager.use_count() != 0)
343 {343 {
344 resources_freed_failure.set();344 resources_freed_failure.set();
345345
=== modified file 'tests/acceptance-tests/test_test_framework.cpp'
--- tests/acceptance-tests/test_test_framework.cpp 2013-04-24 05:22:20 +0000
+++ tests/acceptance-tests/test_test_framework.cpp 2013-09-25 14:20:36 +0000
@@ -18,7 +18,7 @@
1818
19#include "mir_test_framework/display_server_test_fixture.h"19#include "mir_test_framework/display_server_test_fixture.h"
2020
21#include "mir/frontend/communicator.h"21#include "mir/frontend/connector.h"
2222
23#include <gmock/gmock.h>23#include <gmock/gmock.h>
24#include <gtest/gtest.h>24#include <gtest/gtest.h>
2525
=== modified file 'tests/integration-tests/client/test_client_render.cpp'
--- tests/integration-tests/client/test_client_render.cpp 2013-08-28 03:41:48 +0000
+++ tests/integration-tests/client/test_client_render.cpp 2013-09-25 14:20:36 +0000
@@ -27,7 +27,7 @@
27#include "mir_test/stub_server_tool.h"27#include "mir_test/stub_server_tool.h"
28#include "mir_test/test_protobuf_server.h"28#include "mir_test/test_protobuf_server.h"
2929
30#include "mir/frontend/communicator.h"30#include "mir/frontend/connector.h"
3131
32#include <gmock/gmock.h>32#include <gmock/gmock.h>
33#include <thread>33#include <thread>
3434
=== modified file 'tests/integration-tests/shell/test_session.cpp'
--- tests/integration-tests/shell/test_session.cpp 2013-08-28 03:41:48 +0000
+++ tests/integration-tests/shell/test_session.cpp 2013-09-25 14:20:36 +0000
@@ -29,7 +29,7 @@
29#include "mir/surfaces/buffer_stream.h"29#include "mir/surfaces/buffer_stream.h"
30#include "mir/compositor/renderer.h"30#include "mir/compositor/renderer.h"
31#include "mir/compositor/renderer_factory.h"31#include "mir/compositor/renderer_factory.h"
32#include "mir/frontend/communicator.h"32#include "mir/frontend/connector.h"
3333
34#include "mir_test_doubles/stub_buffer.h"34#include "mir_test_doubles/stub_buffer.h"
35#include "mir_test_doubles/null_display.h"35#include "mir_test_doubles/null_display.h"
@@ -61,15 +61,16 @@
61 return input_configuration;61 return input_configuration;
62 }62 }
6363
64 std::shared_ptr<mf::Communicator> the_communicator() override64 std::shared_ptr<mf::Connector> the_connector() override
65 {65 {
66 struct NullCommunicator : public mf::Communicator66 struct NullConnector : public mf::Connector
67 {67 {
68 void start() {}68 void start() {}
69 void stop() {}69 void stop() {}
70 int client_socket_fd() const override { return 0; }
70 };71 };
7172
72 return std::make_shared<NullCommunicator>();73 return std::make_shared<NullConnector>();
73 }74 }
7475
75 std::shared_ptr<mg::GraphicBufferAllocator> the_buffer_allocator() override76 std::shared_ptr<mg::GraphicBufferAllocator> the_buffer_allocator() override
7677
=== modified file 'tests/integration-tests/test_display_server_main_loop_events.cpp'
--- tests/integration-tests/test_display_server_main_loop_events.cpp 2013-09-18 21:09:29 +0000
+++ tests/integration-tests/test_display_server_main_loop_events.cpp 2013-09-25 14:20:36 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19#include "mir/compositor/compositor.h"19#include "mir/compositor/compositor.h"
20#include "mir/frontend/communicator.h"20#include "mir/frontend/connector.h"
21#include "mir/graphics/display_configuration.h"21#include "mir/graphics/display_configuration.h"
22#include "mir/graphics/display_configuration_policy.h"22#include "mir/graphics/display_configuration_policy.h"
23#include "mir/main_loop.h"23#include "mir/main_loop.h"
@@ -53,11 +53,12 @@
53namespace53namespace
54{54{
5555
56class MockCommunicator : public mf::Communicator56class MockConnector : public mf::Connector
57{57{
58public:58public:
59 MOCK_METHOD0(start, void());59 MOCK_METHOD0(start, void());
60 MOCK_METHOD0(stop, void());60 MOCK_METHOD0(stop, void());
61 MOCK_CONST_METHOD0(client_socket_fd, int());
61};62};
6263
63class MockDisplayChanger : public mir::DisplayChanger64class MockDisplayChanger : public mir::DisplayChanger
@@ -226,12 +227,12 @@
226 return mock_compositor;227 return mock_compositor;
227 }228 }
228229
229 std::shared_ptr<mf::Communicator> the_communicator() override230 std::shared_ptr<mf::Connector> the_connector() override
230 {231 {
231 if (!mock_communicator)232 if (!mock_connector)
232 mock_communicator = std::make_shared<MockCommunicator>();233 mock_connector = std::make_shared<MockConnector>();
233234
234 return mock_communicator;235 return mock_connector;
235 }236 }
236237
237 std::shared_ptr<mi::InputManager> the_input_manager() override238 std::shared_ptr<mi::InputManager> the_input_manager() override
@@ -262,10 +263,10 @@
262 return mock_compositor;263 return mock_compositor;
263 }264 }
264265
265 std::shared_ptr<MockCommunicator> the_mock_communicator()266 std::shared_ptr<MockConnector> the_mock_connector()
266 {267 {
267 the_communicator();268 the_connector();
268 return mock_communicator;269 return mock_connector;
269 }270 }
270271
271 std::shared_ptr<mtd::MockInputManager> the_mock_input_manager()272 std::shared_ptr<mtd::MockInputManager> the_mock_input_manager()
@@ -304,7 +305,7 @@
304private:305private:
305 std::shared_ptr<mtd::MockCompositor> mock_compositor;306 std::shared_ptr<mtd::MockCompositor> mock_compositor;
306 std::shared_ptr<MockDisplay> mock_display;307 std::shared_ptr<MockDisplay> mock_display;
307 std::shared_ptr<MockCommunicator> mock_communicator;308 std::shared_ptr<MockConnector> mock_connector;
308 std::shared_ptr<mtd::MockInputManager> mock_input_manager;309 std::shared_ptr<mtd::MockInputManager> mock_input_manager;
309 std::shared_ptr<MockDisplayChanger> mock_display_changer;310 std::shared_ptr<MockDisplayChanger> mock_display_changer;
310311
@@ -410,33 +411,33 @@
410411
411 auto mock_compositor = server_config.the_mock_compositor();412 auto mock_compositor = server_config.the_mock_compositor();
412 auto mock_display = server_config.the_mock_display();413 auto mock_display = server_config.the_mock_display();
413 auto mock_communicator = server_config.the_mock_communicator();414 auto mock_connector = server_config.the_mock_connector();
414 auto mock_input_manager = server_config.the_mock_input_manager();415 auto mock_input_manager = server_config.the_mock_input_manager();
415416
416 {417 {
417 InSequence s;418 InSequence s;
418419
419 /* Start */420 /* Start */
420 EXPECT_CALL(*mock_communicator, start()).Times(1);421 EXPECT_CALL(*mock_connector, start()).Times(1);
421 EXPECT_CALL(*mock_compositor, start()).Times(1);422 EXPECT_CALL(*mock_compositor, start()).Times(1);
422 EXPECT_CALL(*mock_input_manager, start()).Times(1);423 EXPECT_CALL(*mock_input_manager, start()).Times(1);
423424
424 /* Pause */425 /* Pause */
425 EXPECT_CALL(*mock_input_manager, stop()).Times(1);426 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
426 EXPECT_CALL(*mock_compositor, stop()).Times(1);427 EXPECT_CALL(*mock_compositor, stop()).Times(1);
427 EXPECT_CALL(*mock_communicator, stop()).Times(1);428 EXPECT_CALL(*mock_connector, stop()).Times(1);
428 EXPECT_CALL(*mock_display, pause()).Times(1);429 EXPECT_CALL(*mock_display, pause()).Times(1);
429430
430 /* Resume */431 /* Resume */
431 EXPECT_CALL(*mock_display, resume()).Times(1);432 EXPECT_CALL(*mock_display, resume()).Times(1);
432 EXPECT_CALL(*mock_communicator, start()).Times(1);433 EXPECT_CALL(*mock_connector, start()).Times(1);
433 EXPECT_CALL(*mock_input_manager, start()).Times(1);434 EXPECT_CALL(*mock_input_manager, start()).Times(1);
434 EXPECT_CALL(*mock_compositor, start()).Times(1);435 EXPECT_CALL(*mock_compositor, start()).Times(1);
435436
436 /* Stop */437 /* Stop */
437 EXPECT_CALL(*mock_input_manager, stop()).Times(1);438 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
438 EXPECT_CALL(*mock_compositor, stop()).Times(1);439 EXPECT_CALL(*mock_compositor, stop()).Times(1);
439 EXPECT_CALL(*mock_communicator, stop()).Times(1);440 EXPECT_CALL(*mock_connector, stop()).Times(1);
440 }441 }
441442
442 mir::run_mir(server_config,443 mir::run_mir(server_config,
@@ -461,27 +462,27 @@
461462
462 auto mock_compositor = server_config.the_mock_compositor();463 auto mock_compositor = server_config.the_mock_compositor();
463 auto mock_display = server_config.the_mock_display();464 auto mock_display = server_config.the_mock_display();
464 auto mock_communicator = server_config.the_mock_communicator();465 auto mock_connector = server_config.the_mock_connector();
465 auto mock_input_manager = server_config.the_mock_input_manager();466 auto mock_input_manager = server_config.the_mock_input_manager();
466467
467 {468 {
468 InSequence s;469 InSequence s;
469470
470 /* Start */471 /* Start */
471 EXPECT_CALL(*mock_communicator, start()).Times(1);472 EXPECT_CALL(*mock_connector, start()).Times(1);
472 EXPECT_CALL(*mock_compositor, start()).Times(1);473 EXPECT_CALL(*mock_compositor, start()).Times(1);
473 EXPECT_CALL(*mock_input_manager, start()).Times(1);474 EXPECT_CALL(*mock_input_manager, start()).Times(1);
474475
475 /* Pause */476 /* Pause */
476 EXPECT_CALL(*mock_input_manager, stop()).Times(1);477 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
477 EXPECT_CALL(*mock_compositor, stop()).Times(1);478 EXPECT_CALL(*mock_compositor, stop()).Times(1);
478 EXPECT_CALL(*mock_communicator, stop()).Times(1);479 EXPECT_CALL(*mock_connector, stop()).Times(1);
479 EXPECT_CALL(*mock_display, pause()).Times(1);480 EXPECT_CALL(*mock_display, pause()).Times(1);
480481
481 /* Stop */482 /* Stop */
482 EXPECT_CALL(*mock_input_manager, stop()).Times(1);483 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
483 EXPECT_CALL(*mock_compositor, stop()).Times(1);484 EXPECT_CALL(*mock_compositor, stop()).Times(1);
484 EXPECT_CALL(*mock_communicator, stop()).Times(1);485 EXPECT_CALL(*mock_connector, stop()).Times(1);
485 }486 }
486487
487 mir::run_mir(server_config,488 mir::run_mir(server_config,
@@ -505,33 +506,33 @@
505506
506 auto mock_compositor = server_config.the_mock_compositor();507 auto mock_compositor = server_config.the_mock_compositor();
507 auto mock_display = server_config.the_mock_display();508 auto mock_display = server_config.the_mock_display();
508 auto mock_communicator = server_config.the_mock_communicator();509 auto mock_connector = server_config.the_mock_connector();
509 auto mock_input_manager = server_config.the_mock_input_manager();510 auto mock_input_manager = server_config.the_mock_input_manager();
510511
511 {512 {
512 InSequence s;513 InSequence s;
513514
514 /* Start */515 /* Start */
515 EXPECT_CALL(*mock_communicator, start()).Times(1);516 EXPECT_CALL(*mock_connector, start()).Times(1);
516 EXPECT_CALL(*mock_compositor, start()).Times(1);517 EXPECT_CALL(*mock_compositor, start()).Times(1);
517 EXPECT_CALL(*mock_input_manager, start()).Times(1);518 EXPECT_CALL(*mock_input_manager, start()).Times(1);
518519
519 /* Pause failure */520 /* Pause failure */
520 EXPECT_CALL(*mock_input_manager, stop()).Times(1);521 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
521 EXPECT_CALL(*mock_compositor, stop()).Times(1);522 EXPECT_CALL(*mock_compositor, stop()).Times(1);
522 EXPECT_CALL(*mock_communicator, stop()).Times(1);523 EXPECT_CALL(*mock_connector, stop()).Times(1);
523 EXPECT_CALL(*mock_display, pause())524 EXPECT_CALL(*mock_display, pause())
524 .WillOnce(Throw(std::runtime_error("")));525 .WillOnce(Throw(std::runtime_error("")));
525526
526 /* Attempt to continue */527 /* Attempt to continue */
527 EXPECT_CALL(*mock_communicator, start()).Times(1);528 EXPECT_CALL(*mock_connector, start()).Times(1);
528 EXPECT_CALL(*mock_compositor, start()).Times(1);529 EXPECT_CALL(*mock_compositor, start()).Times(1);
529 EXPECT_CALL(*mock_input_manager, start()).Times(1);530 EXPECT_CALL(*mock_input_manager, start()).Times(1);
530531
531 /* Stop */532 /* Stop */
532 EXPECT_CALL(*mock_input_manager, stop()).Times(1);533 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
533 EXPECT_CALL(*mock_compositor, stop()).Times(1);534 EXPECT_CALL(*mock_compositor, stop()).Times(1);
534 EXPECT_CALL(*mock_communicator, stop()).Times(1);535 EXPECT_CALL(*mock_connector, stop()).Times(1);
535 }536 }
536537
537 mir::run_mir(server_config,538 mir::run_mir(server_config,
@@ -555,7 +556,7 @@
555556
556 auto mock_compositor = server_config.the_mock_compositor();557 auto mock_compositor = server_config.the_mock_compositor();
557 auto mock_display = server_config.the_mock_display();558 auto mock_display = server_config.the_mock_display();
558 auto mock_communicator = server_config.the_mock_communicator();559 auto mock_connector = server_config.the_mock_connector();
559 auto mock_input_manager = server_config.the_mock_input_manager();560 auto mock_input_manager = server_config.the_mock_input_manager();
560 auto mock_display_changer = server_config.the_mock_display_changer();561 auto mock_display_changer = server_config.the_mock_display_changer();
561562
@@ -563,7 +564,7 @@
563 InSequence s;564 InSequence s;
564565
565 /* Start */566 /* Start */
566 EXPECT_CALL(*mock_communicator, start()).Times(1);567 EXPECT_CALL(*mock_connector, start()).Times(1);
567 EXPECT_CALL(*mock_compositor, start()).Times(1);568 EXPECT_CALL(*mock_compositor, start()).Times(1);
568 EXPECT_CALL(*mock_input_manager, start()).Times(1);569 EXPECT_CALL(*mock_input_manager, start()).Times(1);
569570
@@ -575,7 +576,7 @@
575 /* Stop */576 /* Stop */
576 EXPECT_CALL(*mock_input_manager, stop()).Times(1);577 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
577 EXPECT_CALL(*mock_compositor, stop()).Times(1);578 EXPECT_CALL(*mock_compositor, stop()).Times(1);
578 EXPECT_CALL(*mock_communicator, stop()).Times(1);579 EXPECT_CALL(*mock_connector, stop()).Times(1);
579 }580 }
580581
581 mir::run_mir(server_config,582 mir::run_mir(server_config,
@@ -599,7 +600,7 @@
599600
600 auto mock_compositor = server_config.the_mock_compositor();601 auto mock_compositor = server_config.the_mock_compositor();
601 auto mock_display = server_config.the_mock_display();602 auto mock_display = server_config.the_mock_display();
602 auto mock_communicator = server_config.the_mock_communicator();603 auto mock_connector = server_config.the_mock_connector();
603 auto mock_input_manager = server_config.the_mock_input_manager();604 auto mock_input_manager = server_config.the_mock_input_manager();
604 auto mock_display_changer = server_config.the_mock_display_changer();605 auto mock_display_changer = server_config.the_mock_display_changer();
605606
@@ -607,19 +608,19 @@
607 InSequence s;608 InSequence s;
608609
609 /* Start */610 /* Start */
610 EXPECT_CALL(*mock_communicator, start()).Times(1);611 EXPECT_CALL(*mock_connector, start()).Times(1);
611 EXPECT_CALL(*mock_compositor, start()).Times(1);612 EXPECT_CALL(*mock_compositor, start()).Times(1);
612 EXPECT_CALL(*mock_input_manager, start()).Times(1);613 EXPECT_CALL(*mock_input_manager, start()).Times(1);
613614
614 /* Pause event */615 /* Pause event */
615 EXPECT_CALL(*mock_input_manager, stop()).Times(1);616 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
616 EXPECT_CALL(*mock_compositor, stop()).Times(1);617 EXPECT_CALL(*mock_compositor, stop()).Times(1);
617 EXPECT_CALL(*mock_communicator, stop()).Times(1);618 EXPECT_CALL(*mock_connector, stop()).Times(1);
618 EXPECT_CALL(*mock_display, pause()) .Times(1);619 EXPECT_CALL(*mock_display, pause()) .Times(1);
619620
620 /* Resume and reconfigure event */621 /* Resume and reconfigure event */
621 EXPECT_CALL(*mock_display, resume()).Times(1);622 EXPECT_CALL(*mock_display, resume()).Times(1);
622 EXPECT_CALL(*mock_communicator, start()).Times(1);623 EXPECT_CALL(*mock_connector, start()).Times(1);
623624
624 EXPECT_CALL(*mock_display_changer,625 EXPECT_CALL(*mock_display_changer,
625 configure_for_hardware_change(_, mir::DisplayChanger::RetainSystemState))626 configure_for_hardware_change(_, mir::DisplayChanger::RetainSystemState))
@@ -631,7 +632,7 @@
631 /* Stop */632 /* Stop */
632 EXPECT_CALL(*mock_input_manager, stop()).Times(1);633 EXPECT_CALL(*mock_input_manager, stop()).Times(1);
633 EXPECT_CALL(*mock_compositor, stop()).Times(1);634 EXPECT_CALL(*mock_compositor, stop()).Times(1);
634 EXPECT_CALL(*mock_communicator, stop()).Times(1);635 EXPECT_CALL(*mock_connector, stop()).Times(1);
635 }636 }
636637
637 mir::run_mir(server_config,638 mir::run_mir(server_config,
638639
=== modified file 'tests/integration-tests/test_error_reporting.cpp'
--- tests/integration-tests/test_error_reporting.cpp 2013-08-28 03:41:48 +0000
+++ tests/integration-tests/test_error_reporting.cpp 2013-09-25 14:20:36 +0000
@@ -21,7 +21,7 @@
2121
22#include "mir/frontend/protobuf_ipc_factory.h"22#include "mir/frontend/protobuf_ipc_factory.h"
23#include "mir/frontend/resource_cache.h"23#include "mir/frontend/resource_cache.h"
24#include "mir/frontend/communicator.h"24#include "mir/frontend/connector.h"
2525
26#include "mir_protobuf.pb.h"26#include "mir_protobuf.pb.h"
2727
2828
=== modified file 'tests/mir_test_doubles/test_protobuf_socket_server.cpp'
--- tests/mir_test_doubles/test_protobuf_socket_server.cpp 2013-08-28 03:41:48 +0000
+++ tests/mir_test_doubles/test_protobuf_socket_server.cpp 2013-09-25 14:20:36 +0000
@@ -19,8 +19,9 @@
19#include "mir_test/test_protobuf_server.h"19#include "mir_test/test_protobuf_server.h"
20#include "mir_test_doubles/stub_ipc_factory.h"20#include "mir_test_doubles/stub_ipc_factory.h"
21#include "mir_test_doubles/stub_session_authorizer.h"21#include "mir_test_doubles/stub_session_authorizer.h"
22#include "mir/frontend/communicator_report.h"22#include "mir/frontend/connector_report.h"
23#include "src/server/frontend/protobuf_socket_communicator.h"23#include "src/server/frontend/published_socket_connector.h"
24#include "src/server/frontend/protobuf_session_creator.h"
2425
25namespace mt = mir::test;26namespace mt = mir::test;
26namespace mtd = mir::test::doubles;27namespace mtd = mir::test::doubles;
@@ -28,15 +29,14 @@
2829
29namespace30namespace
30{31{
31std::shared_ptr<mf::Communicator> make_communicator(32std::shared_ptr<mf::Connector> make_connector(
32 std::string const& socket_name,33 std::string const& socket_name,
33 std::shared_ptr<mf::ProtobufIpcFactory> const& factory,34 std::shared_ptr<mf::ProtobufIpcFactory> const& factory,
34 std::shared_ptr<mf::CommunicatorReport> const& report)35 std::shared_ptr<mf::ConnectorReport> const& report)
35{36{
36 return std::make_shared<mf::ProtobufSocketCommunicator>(37 return std::make_shared<mf::PublishedSocketConnector>(
37 socket_name,38 socket_name,
38 factory,39 std::make_shared<mf::ProtobufSessionCreator>(factory, std::make_shared<mtd::StubSessionAuthorizer>()),
39 std::make_shared<mtd::StubSessionAuthorizer>(),
40 10,40 10,
41 []{},41 []{},
42 report);42 report);
@@ -46,14 +46,14 @@
46mt::TestProtobufServer::TestProtobufServer(46mt::TestProtobufServer::TestProtobufServer(
47 std::string const& socket_name,47 std::string const& socket_name,
48 const std::shared_ptr<protobuf::DisplayServer>& tool) :48 const std::shared_ptr<protobuf::DisplayServer>& tool) :
49 TestProtobufServer(socket_name, tool, std::make_shared<mf::NullCommunicatorReport>())49 TestProtobufServer(socket_name, tool, std::make_shared<mf::NullConnectorReport>())
50{50{
51}51}
5252
53mt::TestProtobufServer::TestProtobufServer(53mt::TestProtobufServer::TestProtobufServer(
54 std::string const& socket_name,54 std::string const& socket_name,
55 const std::shared_ptr<protobuf::DisplayServer>& tool,55 const std::shared_ptr<protobuf::DisplayServer>& tool,
56 std::shared_ptr<frontend::CommunicatorReport> const& report) :56 std::shared_ptr<frontend::ConnectorReport> const& report) :
57 comm(make_communicator(socket_name, std::make_shared<mtd::StubIpcFactory>(*tool), report))57 comm(make_connector(socket_name, std::make_shared<mtd::StubIpcFactory>(*tool), report))
58{58{
59}59}
6060
=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
--- tests/unit-tests/client/test_client_mir_surface.cpp 2013-08-28 03:41:48 +0000
+++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-09-25 14:20:36 +0000
@@ -30,7 +30,7 @@
30#include "src/client/rpc/mir_basic_rpc_channel.h"30#include "src/client/rpc/mir_basic_rpc_channel.h"
3131
32#include "mir/frontend/resource_cache.h"32#include "mir/frontend/resource_cache.h"
33#include "mir/frontend/communicator.h"33#include "mir/frontend/connector.h"
34#include "mir/input/input_platform.h"34#include "mir/input/input_platform.h"
35#include "mir/input/input_receiver_thread.h"35#include "mir/input/input_receiver_thread.h"
3636
3737
=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
--- tests/unit-tests/frontend/CMakeLists.txt 2013-08-28 03:41:48 +0000
+++ tests/unit-tests/frontend/CMakeLists.txt 2013-09-25 14:20:36 +0000
@@ -1,7 +1,7 @@
1list(APPEND UNIT_TEST_SOURCES1list(APPEND UNIT_TEST_SOURCES
2 ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffer_tracker.cpp2 ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffer_tracker.cpp
3 ${CMAKE_CURRENT_SOURCE_DIR}/stress_protobuf_communicator.cpp3 ${CMAKE_CURRENT_SOURCE_DIR}/stress_protobuf_communicator.cpp
4 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_communicator.cpp4 ${CMAKE_CURRENT_SOURCE_DIR}/test_published_socket_connector.cpp
5 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_surface_apis.cpp5 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_surface_apis.cpp
6 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_buffer_packer.cpp7 ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_buffer_packer.cpp
88
=== modified file 'tests/unit-tests/frontend/stress_protobuf_communicator.cpp'
--- tests/unit-tests/frontend/stress_protobuf_communicator.cpp 2013-08-28 03:41:48 +0000
+++ tests/unit-tests/frontend/stress_protobuf_communicator.cpp 2013-09-25 14:20:36 +0000
@@ -16,7 +16,7 @@
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */17 */
1818
19#include "mir/frontend/communicator.h"19#include "mir/frontend/connector.h"
20#include "mir/frontend/resource_cache.h"20#include "mir/frontend/resource_cache.h"
2121
22#include "mir_protobuf.pb.h"22#include "mir_protobuf.pb.h"
2323
=== modified file 'tests/unit-tests/frontend/test_protobuf_reports_errors.cpp'
--- tests/unit-tests/frontend/test_protobuf_reports_errors.cpp 2013-06-19 16:14:40 +0000
+++ tests/unit-tests/frontend/test_protobuf_reports_errors.cpp 2013-09-25 14:20:36 +0000
@@ -17,7 +17,7 @@
17 * Alan Griffiths <alan@octopull.co.uk>17 * Alan Griffiths <alan@octopull.co.uk>
18 */18 */
1919
20#include "mir/frontend/communicator.h"20#include "mir/frontend/connector.h"
21#include "mir/frontend/resource_cache.h"21#include "mir/frontend/resource_cache.h"
2222
23#include "mir_test/stub_server_tool.h"23#include "mir_test/stub_server_tool.h"
2424
=== modified file 'tests/unit-tests/frontend/test_protobuf_sends_fds.cpp'
--- tests/unit-tests/frontend/test_protobuf_sends_fds.cpp 2013-06-03 08:14:01 +0000
+++ tests/unit-tests/frontend/test_protobuf_sends_fds.cpp 2013-09-25 14:20:36 +0000
@@ -17,7 +17,7 @@
17 * Alan Griffiths <alan@octopull.co.uk>17 * Alan Griffiths <alan@octopull.co.uk>
18 */18 */
1919
20#include "mir/frontend/communicator.h"20#include "mir/frontend/connector.h"
21#include "mir/frontend/resource_cache.h"21#include "mir/frontend/resource_cache.h"
2222
23#include "mir_protobuf.pb.h"23#include "mir_protobuf.pb.h"
2424
=== modified file 'tests/unit-tests/frontend/test_protobuf_surface_apis.cpp'
--- tests/unit-tests/frontend/test_protobuf_surface_apis.cpp 2013-06-03 08:14:01 +0000
+++ tests/unit-tests/frontend/test_protobuf_surface_apis.cpp 2013-09-25 14:20:36 +0000
@@ -17,7 +17,7 @@
17 * Alan Griffiths <alan@octopull.co.uk>17 * Alan Griffiths <alan@octopull.co.uk>
18 */18 */
1919
20#include "mir/frontend/communicator.h"20#include "mir/frontend/connector.h"
21#include "mir/frontend/resource_cache.h"21#include "mir/frontend/resource_cache.h"
2222
23#include "mir_protobuf.pb.h"23#include "mir_protobuf.pb.h"
2424
=== renamed file 'tests/unit-tests/frontend/test_protobuf_communicator.cpp' => 'tests/unit-tests/frontend/test_published_socket_connector.cpp'
--- tests/unit-tests/frontend/test_protobuf_communicator.cpp 2013-08-28 03:41:48 +0000
+++ tests/unit-tests/frontend/test_published_socket_connector.cpp 2013-09-25 14:20:36 +0000
@@ -17,10 +17,11 @@
17 * Alan Griffiths <alan@octopull.co.uk>17 * Alan Griffiths <alan@octopull.co.uk>
18 */18 */
1919
20#include "mir/frontend/communicator.h"20#include "mir/frontend/connector.h"
21#include "mir/frontend/communicator_report.h"21#include "mir/frontend/connector_report.h"
22#include "mir/frontend/resource_cache.h"22#include "mir/frontend/resource_cache.h"
23#include "src/server/frontend/protobuf_socket_communicator.h"23#include "src/server/frontend/published_socket_connector.h"
24#include "src/server/frontend/protobuf_session_creator.h"
2425
25#include "mir_protobuf.pb.h"26#include "mir_protobuf.pb.h"
2627
@@ -45,7 +46,7 @@
4546
46namespace47namespace
47{48{
48class MockCommunicatorReport : public mf::CommunicatorReport49class MockCommunicatorReport : public mf::ConnectorReport
49{50{
50public:51public:
5152
@@ -55,20 +56,21 @@
55};56};
56}57}
5758
58struct ProtobufCommunicator : public ::testing::Test59struct PublishedSocketConnector : public ::testing::Test
59{60{
60 static void SetUpTestCase()61 static void SetUpTestCase()
61 {62 {
63 }
64
65 void SetUp()
66 {
62 communicator_report = std::make_shared<MockCommunicatorReport>();67 communicator_report = std::make_shared<MockCommunicatorReport>();
63 stub_server_tool = std::make_shared<mt::StubServerTool>();68 stub_server_tool = std::make_shared<mt::StubServerTool>();
64 stub_server = std::make_shared<mt::TestProtobufServer>(69 stub_server = std::make_shared<mt::TestProtobufServer>(
65 "./test_socket",70 "./test_socket",
66 stub_server_tool,71 stub_server_tool,
67 communicator_report);72 communicator_report);
68 }
6973
70 void SetUp()
71 {
72 using namespace testing;74 using namespace testing;
73 EXPECT_CALL(*communicator_report, error(_)).Times(AnyNumber());75 EXPECT_CALL(*communicator_report, error(_)).Times(AnyNumber());
74 stub_server->comm->start();76 stub_server->comm->start();
@@ -81,27 +83,27 @@
81 stub_server->comm->stop();83 stub_server->comm->stop();
82 testing::Mock::VerifyAndClearExpectations(communicator_report.get());84 testing::Mock::VerifyAndClearExpectations(communicator_report.get());
83 client.reset();85 client.reset();
84 }
8586
86 static void TearDownTestCase()
87 {
88 stub_server.reset();87 stub_server.reset();
89 stub_server_tool.reset();88 stub_server_tool.reset();
90 communicator_report.reset();89 communicator_report.reset();
91 }90 }
9291
92 static void TearDownTestCase()
93 {
94 }
95
93 std::shared_ptr<mt::TestProtobufClient> client;96 std::shared_ptr<mt::TestProtobufClient> client;
94 static std::shared_ptr<MockCommunicatorReport> communicator_report;97 static std::shared_ptr<MockCommunicatorReport> communicator_report;
95 static std::shared_ptr<mt::StubServerTool> stub_server_tool;98 static std::shared_ptr<mt::StubServerTool> stub_server_tool;
96private:
97 static std::shared_ptr<mt::TestProtobufServer> stub_server;99 static std::shared_ptr<mt::TestProtobufServer> stub_server;
98};100};
99101
100std::shared_ptr<mt::StubServerTool> ProtobufCommunicator::stub_server_tool;102std::shared_ptr<mt::StubServerTool> PublishedSocketConnector::stub_server_tool;
101std::shared_ptr<MockCommunicatorReport> ProtobufCommunicator::communicator_report;103std::shared_ptr<MockCommunicatorReport> PublishedSocketConnector::communicator_report;
102std::shared_ptr<mt::TestProtobufServer> ProtobufCommunicator::stub_server;104std::shared_ptr<mt::TestProtobufServer> PublishedSocketConnector::stub_server;
103105
104TEST_F(ProtobufCommunicator, create_surface_results_in_a_callback)106TEST_F(PublishedSocketConnector, create_surface_results_in_a_callback)
105{107{
106 EXPECT_CALL(*client, create_surface_done()).Times(1);108 EXPECT_CALL(*client, create_surface_done()).Times(1);
107109
@@ -114,7 +116,7 @@
114 client->wait_for_create_surface();116 client->wait_for_create_surface();
115}117}
116118
117TEST_F(ProtobufCommunicator, connection_sets_app_name)119TEST_F(PublishedSocketConnector, connection_sets_app_name)
118{120{
119 EXPECT_CALL(*client, connect_done()).Times(1);121 EXPECT_CALL(*client, connect_done()).Times(1);
120122
@@ -131,7 +133,7 @@
131 EXPECT_EQ(__PRETTY_FUNCTION__, stub_server_tool->app_name);133 EXPECT_EQ(__PRETTY_FUNCTION__, stub_server_tool->app_name);
132}134}
133135
134TEST_F(ProtobufCommunicator, create_surface_sets_surface_name)136TEST_F(PublishedSocketConnector, create_surface_sets_surface_name)
135{137{
136 EXPECT_CALL(*client, connect_done()).Times(1);138 EXPECT_CALL(*client, connect_done()).Times(1);
137 EXPECT_CALL(*client, create_surface_done()).Times(1);139 EXPECT_CALL(*client, create_surface_done()).Times(1);
@@ -160,7 +162,7 @@
160}162}
161163
162164
163TEST_F(ProtobufCommunicator,165TEST_F(PublishedSocketConnector,
164 create_surface_results_in_a_surface_being_created)166 create_surface_results_in_a_surface_being_created)
165{167{
166 EXPECT_CALL(*client, create_surface_done()).Times(1);168 EXPECT_CALL(*client, create_surface_done()).Times(1);
@@ -184,7 +186,7 @@
184186
185}187}
186188
187TEST_F(ProtobufCommunicator, double_disconnection_attempt_throws_exception)189TEST_F(PublishedSocketConnector, double_disconnection_attempt_throws_exception)
188{190{
189 using namespace testing;191 using namespace testing;
190192
@@ -219,7 +221,7 @@
219 }, std::runtime_error);221 }, std::runtime_error);
220}222}
221223
222TEST_F(ProtobufCommunicator, getting_and_advancing_buffers)224TEST_F(PublishedSocketConnector, getting_and_advancing_buffers)
223{225{
224 EXPECT_CALL(*client, create_surface_done()).Times(testing::AtLeast(0));226 EXPECT_CALL(*client, create_surface_done()).Times(testing::AtLeast(0));
225 EXPECT_CALL(*client, disconnect_done()).Times(testing::AtLeast(0));227 EXPECT_CALL(*client, disconnect_done()).Times(testing::AtLeast(0));
@@ -256,7 +258,7 @@
256 client->wait_for_disconnect_done();258 client->wait_for_disconnect_done();
257}259}
258260
259TEST_F(ProtobufCommunicator,261TEST_F(PublishedSocketConnector,
260 connect_create_surface_then_disconnect_a_session)262 connect_create_surface_then_disconnect_a_session)
261{263{
262 EXPECT_CALL(*client, create_surface_done()).Times(1);264 EXPECT_CALL(*client, create_surface_done()).Times(1);
@@ -278,7 +280,7 @@
278 client->wait_for_disconnect_done();280 client->wait_for_disconnect_done();
279}281}
280282
281TEST_F(ProtobufCommunicator, drm_auth_magic_is_processed_by_the_server)283TEST_F(PublishedSocketConnector, drm_auth_magic_is_processed_by_the_server)
282{284{
283 mir::protobuf::DRMMagic magic;285 mir::protobuf::DRMMagic magic;
284 mir::protobuf::DRMAuthMagicStatus status;286 mir::protobuf::DRMAuthMagicStatus status;
@@ -308,7 +310,7 @@
308310
309}311}
310312
311TEST_F(ProtobufCommunicator, forces_requests_to_complete_when_stopping)313TEST_F(PublishedSocketConnector, forces_requests_to_complete_when_stopping)
312{314{
313 MockForceRequests mock_force_requests;315 MockForceRequests mock_force_requests;
314 auto stub_server_tool = std::make_shared<mt::StubServerTool>();316 auto stub_server_tool = std::make_shared<mt::StubServerTool>();
@@ -318,17 +320,18 @@
318 EXPECT_CALL(mock_force_requests, force_requests_to_complete())320 EXPECT_CALL(mock_force_requests, force_requests_to_complete())
319 .Times(2);321 .Times(2);
320322
321 auto comms = std::make_shared<mf::ProtobufSocketCommunicator>(323 auto comms = std::make_shared<mf::PublishedSocketConnector>(
322 "./test_socket1", ipc_factory, 324 "./test_socket1",
323 std::make_shared<mtd::StubSessionAuthorizer>(), 10,325 std::make_shared<mf::ProtobufSessionCreator>(ipc_factory, std::make_shared<mtd::StubSessionAuthorizer>()),
324 std::bind(&MockForceRequests::force_requests_to_complete,326 10,
325 &mock_force_requests),327 std::bind(&MockForceRequests::force_requests_to_complete, &mock_force_requests),
326 std::make_shared<mf::NullCommunicatorReport>());328 std::make_shared<mf::NullConnectorReport>());
329
327 comms->start();330 comms->start();
328 comms->stop();331 comms->stop();
329}332}
330333
331TEST_F(ProtobufCommunicator, disorderly_disconnection_handled)334TEST_F(PublishedSocketConnector, disorderly_disconnection_handled)
332{335{
333 using namespace testing;336 using namespace testing;
334337
@@ -363,7 +366,7 @@
363 while (!done && cv.wait_until(lock, deadline) != std::cv_status::timeout);366 while (!done && cv.wait_until(lock, deadline) != std::cv_status::timeout);
364}367}
365368
366TEST_F(ProtobufCommunicator, configure_display)369TEST_F(PublishedSocketConnector, configure_display)
367{370{
368 EXPECT_CALL(*client, display_configure_done())371 EXPECT_CALL(*client, display_configure_done())
369 .Times(1);372 .Times(1);
@@ -376,3 +379,57 @@
376379
377 client->wait_for_configure_display_done();380 client->wait_for_configure_display_done();
378}381}
382
383TEST_F(PublishedSocketConnector, connection_using_socket_fd)
384{
385 int const next_buffer_calls{8};
386 char buffer[128] = {0};
387 sprintf(buffer, "fd://%d", stub_server->comm->client_socket_fd());
388 auto client = std::make_shared<mt::TestProtobufClient>(buffer, 100);
389 client->connect_parameters.set_application_name(__PRETTY_FUNCTION__);
390
391 EXPECT_CALL(*client, connect_done()).Times(1);
392
393 client->display_server.connect(
394 0,
395 &client->connect_parameters,
396 &client->connection,
397 google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::connect_done));
398
399 EXPECT_CALL(*client, create_surface_done()).Times(testing::AtLeast(0));
400 EXPECT_CALL(*client, disconnect_done()).Times(testing::AtLeast(0));
401
402 client->display_server.create_surface(
403 0,
404 &client->surface_parameters,
405 &client->surface,
406 google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::create_surface_done));
407
408 client->wait_for_create_surface();
409
410 EXPECT_TRUE(client->surface.has_buffer());
411 EXPECT_CALL(*client, next_buffer_done()).Times(next_buffer_calls);
412
413 for (int i = 0; i != next_buffer_calls; ++i)
414 {
415 client->display_server.next_buffer(
416 0,
417 &client->surface.id(),
418 client->surface.mutable_buffer(),
419 google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::next_buffer_done));
420
421 client->wait_for_next_buffer();
422 EXPECT_TRUE(client->surface.has_buffer());
423 }
424
425 client->display_server.disconnect(
426 0,
427 &client->ignored,
428 &client->ignored,
429 google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::disconnect_done));
430
431 client->wait_for_disconnect_done();
432
433 EXPECT_EQ(__PRETTY_FUNCTION__, stub_server_tool->app_name);
434}
435

Subscribers

People subscribed via source and target branches