Merge lp:~alan-griffiths/mir/socket-connection into lp:mir
- socket-connection
- Merge into development-branch
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 | ||||||||||||
Related bugs: |
|
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.
PS Jenkins bot (ps-jenkins) wrote : | # |
Kevin DuBois (kdub) wrote : | # |
read through once, looks okay to me. want to look it over again, abstain for now
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1099
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
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_
1735 +
1736 + for (int i = 0; i != 8; ++i)
int const num_buffer_
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1100
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1101
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Alexandros Frantzis (afrantzis) wrote : | # |
Looks good.
Nits:
496 +char const* const no_server_
Not used.
504 + return std::make_
505 + the_ipc_
506 + the_buffer_
Current indentation makes the_buffer_
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1103
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
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://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
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_
create_
are we creating a session for the socket? or creating a session with a socket? create_
those are pretty minor naming issues though, lgtm
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'examples/basic_server.cpp' |
2 | --- examples/basic_server.cpp 2013-08-29 03:48:16 +0000 |
3 | +++ examples/basic_server.cpp 2013-09-25 14:20:36 +0000 |
4 | @@ -16,18 +16,53 @@ |
5 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
6 | */ |
7 | |
8 | +#include "server_configuration.h" |
9 | + |
10 | +#include "mir/abnormal_exit.h" |
11 | +#include "mir/frontend/connector.h" |
12 | +#include "mir/options/option.h" |
13 | +#include "mir/report_exception.h" |
14 | #include "mir/run_mir.h" |
15 | -#include "mir/report_exception.h" |
16 | -#include "server_configuration.h" |
17 | |
18 | #include <iostream> |
19 | |
20 | +namespace |
21 | +{ |
22 | +char const* const launch_child_opt = "launch-client"; |
23 | + |
24 | +struct ServerConfiguration : mir::examples::ServerConfiguration |
25 | +{ |
26 | + ServerConfiguration(int argc, char const** argv) : |
27 | + mir::examples::ServerConfiguration(argc, argv) |
28 | + { |
29 | + namespace po = boost::program_options; |
30 | + |
31 | + add_options() |
32 | + (launch_child_opt, po::value<std::string>(), "system() command to launch client"); |
33 | + } |
34 | + |
35 | + void launch_client() |
36 | + { |
37 | + if (the_options()->is_set(launch_child_opt)) |
38 | + { |
39 | + char buffer[128] = {0}; |
40 | + sprintf(buffer, "fd://%d", the_connector()->client_socket_fd()); |
41 | + setenv("MIR_SOCKET", buffer, 1); |
42 | + auto ignore = system((the_options()->get(launch_child_opt, "") + "&").c_str()); |
43 | + (void)ignore; |
44 | + } |
45 | + } |
46 | + |
47 | + using mir::examples::ServerConfiguration::the_options; |
48 | +}; |
49 | +} |
50 | + |
51 | int main(int argc, char const* argv[]) |
52 | try |
53 | { |
54 | - mir::examples::ServerConfiguration config(argc, argv); |
55 | + ServerConfiguration config(argc, argv); |
56 | |
57 | - run_mir(config, [](mir::DisplayServer&) {/* empty init */}); |
58 | + run_mir(config, [&](mir::DisplayServer&){ config.launch_client(); }); |
59 | return 0; |
60 | } |
61 | catch (...) |
62 | |
63 | === modified file 'examples/render_surfaces.cpp' |
64 | --- examples/render_surfaces.cpp 2013-09-19 13:24:22 +0000 |
65 | +++ examples/render_surfaces.cpp 2013-09-25 14:20:36 +0000 |
66 | @@ -19,7 +19,7 @@ |
67 | #include "mir/compositor/default_display_buffer_compositor_factory.h" |
68 | #include "mir/compositor/display_buffer_compositor.h" |
69 | #include "mir/graphics/graphic_buffer_allocator.h" |
70 | -#include "mir/frontend/communicator.h" |
71 | +#include "mir/frontend/connector.h" |
72 | #include "mir/shell/surface_creation_parameters.h" |
73 | #include "mir/geometry/size.h" |
74 | #include "mir/geometry/rectangles.h" |
75 | @@ -266,15 +266,16 @@ |
76 | |
77 | ///\internal [RenderSurfacesServerConfiguration_stubs_tag] |
78 | // Stub out server connectivity. |
79 | - std::shared_ptr<mf::Communicator> the_communicator() override |
80 | + std::shared_ptr<mf::Connector> the_connector() override |
81 | { |
82 | - struct NullCommunicator : public mf::Communicator |
83 | + struct NullConnector : public mf::Connector |
84 | { |
85 | void start() {} |
86 | void stop() {} |
87 | + int client_socket_fd() const override { return 0; } |
88 | }; |
89 | |
90 | - return std::make_shared<NullCommunicator>(); |
91 | + return std::make_shared<NullConnector>(); |
92 | } |
93 | ///\internal [RenderSurfacesServerConfiguration_stubs_tag] |
94 | |
95 | |
96 | === modified file 'include/server/mir/default_server_configuration.h' |
97 | --- include/server/mir/default_server_configuration.h 2013-09-23 13:37:44 +0000 |
98 | +++ include/server/mir/default_server_configuration.h 2013-09-25 14:20:36 +0000 |
99 | @@ -41,8 +41,9 @@ |
100 | namespace frontend |
101 | { |
102 | class Shell; |
103 | -class Communicator; |
104 | +class Connector; |
105 | class ProtobufIpcFactory; |
106 | +class SessionCreator; |
107 | class SessionMediatorReport; |
108 | class MessageProcessorReport; |
109 | class SessionAuthorizer; |
110 | @@ -118,7 +119,7 @@ |
111 | /** @name DisplayServer dependencies |
112 | * dependencies of DisplayServer on the rest of the Mir |
113 | * @{ */ |
114 | - virtual std::shared_ptr<frontend::Communicator> the_communicator(); |
115 | + virtual std::shared_ptr<frontend::Connector> the_connector(); |
116 | virtual std::shared_ptr<graphics::Display> the_display(); |
117 | virtual std::shared_ptr<compositor::Compositor> the_compositor(); |
118 | virtual std::shared_ptr<input::InputManager> the_input_manager(); |
119 | @@ -168,6 +169,11 @@ |
120 | virtual std::shared_ptr<frontend::Shell> the_frontend_shell(); |
121 | virtual std::shared_ptr<frontend::EventSink> the_global_event_sink(); |
122 | virtual std::shared_ptr<frontend::DisplayChanger> the_frontend_display_changer(); |
123 | + /** @name frontend configuration - internal dependencies |
124 | + * internal dependencies of frontend |
125 | + * @{ */ |
126 | + virtual std::shared_ptr<frontend::SessionCreator> the_session_creator(); |
127 | + /** @} */ |
128 | /** @} */ |
129 | |
130 | virtual std::shared_ptr<shell::FocusController> the_focus_controller(); |
131 | @@ -243,7 +249,7 @@ |
132 | virtual std::shared_ptr<shell::MediatingDisplayChanger> the_mediating_display_changer(); |
133 | virtual std::shared_ptr<shell::BroadcastingSessionEventSink> the_broadcasting_session_event_sink(); |
134 | |
135 | - CachedPtr<frontend::Communicator> communicator; |
136 | + CachedPtr<frontend::Connector> connector; |
137 | CachedPtr<shell::SessionManager> session_manager; |
138 | |
139 | |
140 | @@ -266,6 +272,7 @@ |
141 | CachedPtr<frontend::MessageProcessorReport> message_processor_report; |
142 | CachedPtr<frontend::SessionAuthorizer> session_authorizer; |
143 | CachedPtr<frontend::EventSink> global_event_sink; |
144 | + CachedPtr<frontend::SessionCreator> session_creator; |
145 | CachedPtr<compositor::RendererFactory> renderer_factory; |
146 | CachedPtr<compositor::BufferStreamFactory> buffer_stream_factory; |
147 | CachedPtr<surfaces::SurfaceStack> surface_stack; |
148 | |
149 | === renamed file 'include/server/mir/frontend/communicator.h' => 'include/server/mir/frontend/connector.h' |
150 | --- include/server/mir/frontend/communicator.h 2013-04-25 09:48:54 +0000 |
151 | +++ include/server/mir/frontend/connector.h 2013-09-25 14:20:36 +0000 |
152 | @@ -16,29 +16,29 @@ |
153 | * Authored by: Thomas Voss <thomas.voss@canonical.com> |
154 | */ |
155 | |
156 | -#ifndef MIR_FRONTEND_COMMUNICATOR_H_ |
157 | -#define MIR_FRONTEND_COMMUNICATOR_H_ |
158 | +#ifndef MIR_FRONTEND_CONNECTOR_H_ |
159 | +#define MIR_FRONTEND_CONNECTOR_H_ |
160 | |
161 | namespace mir |
162 | { |
163 | namespace frontend |
164 | { |
165 | - |
166 | -class Communicator |
167 | +/// Handle client process connections |
168 | +class Connector |
169 | { |
170 | public: |
171 | - virtual ~Communicator() {} |
172 | - |
173 | virtual void start() = 0; |
174 | virtual void stop() = 0; |
175 | |
176 | + virtual int client_socket_fd() const = 0; |
177 | + |
178 | protected: |
179 | - Communicator() = default; |
180 | - Communicator(const Communicator&) = delete; |
181 | - Communicator& operator=(const Communicator&) = delete; |
182 | + Connector() = default; |
183 | + virtual ~Connector() = default; |
184 | + Connector(const Connector&) = delete; |
185 | + Connector& operator=(const Connector&) = delete; |
186 | }; |
187 | - |
188 | -} |
189 | -} |
190 | - |
191 | -#endif // MIR_FRONTEND_COMMUNICATOR_H_ |
192 | +} |
193 | +} |
194 | + |
195 | +#endif // MIR_FRONTEND_CONNECTOR_H_ |
196 | |
197 | === renamed file 'include/server/mir/frontend/communicator_report.h' => 'include/server/mir/frontend/connector_report.h' |
198 | --- include/server/mir/frontend/communicator_report.h 2013-06-19 16:14:40 +0000 |
199 | +++ include/server/mir/frontend/connector_report.h 2013-09-25 14:20:36 +0000 |
200 | @@ -16,8 +16,8 @@ |
201 | * Authored by: Alan Griffiths <alan@octopull.co.uk |
202 | */ |
203 | |
204 | -#ifndef MIR_FRONTEND_COMMUNICATOR_REPORT_H_ |
205 | -#define MIR_FRONTEND_COMMUNICATOR_REPORT_H_ |
206 | +#ifndef MIR_FRONTEND_CONNECTOR_REPORT_H_ |
207 | +#define MIR_FRONTEND_CONNECTOR_REPORT_H_ |
208 | |
209 | #include <stdexcept> |
210 | |
211 | @@ -26,20 +26,20 @@ |
212 | namespace frontend |
213 | { |
214 | |
215 | -class CommunicatorReport |
216 | +class ConnectorReport |
217 | { |
218 | public: |
219 | |
220 | virtual void error(std::exception const& error) = 0; |
221 | |
222 | protected: |
223 | - virtual ~CommunicatorReport() = default; |
224 | - CommunicatorReport() = default; |
225 | - CommunicatorReport(const CommunicatorReport&) = delete; |
226 | - CommunicatorReport& operator=(const CommunicatorReport&) = delete; |
227 | + virtual ~ConnectorReport() = default; |
228 | + ConnectorReport() = default; |
229 | + ConnectorReport(const ConnectorReport&) = delete; |
230 | + ConnectorReport& operator=(const ConnectorReport&) = delete; |
231 | }; |
232 | |
233 | -class NullCommunicatorReport : public CommunicatorReport |
234 | +class NullConnectorReport : public ConnectorReport |
235 | { |
236 | public: |
237 | |
238 | @@ -48,4 +48,4 @@ |
239 | } |
240 | } |
241 | |
242 | -#endif // MIR_FRONTEND_COMMUNICATOR_REPORT_H_ |
243 | +#endif // MIR_FRONTEND_CONNECTOR_REPORT_H_ |
244 | |
245 | === added file 'include/server/mir/frontend/session_creator.h' |
246 | --- include/server/mir/frontend/session_creator.h 1970-01-01 00:00:00 +0000 |
247 | +++ include/server/mir/frontend/session_creator.h 2013-09-25 14:20:36 +0000 |
248 | @@ -0,0 +1,44 @@ |
249 | +/* |
250 | + * Copyright © 2013 Canonical Ltd. |
251 | + * |
252 | + * This program is free software: you can redistribute it and/or modify it |
253 | + * under the terms of the GNU General Public License version 3, |
254 | + * as published by the Free Software Foundation. |
255 | + * |
256 | + * This program is distributed in the hope that it will be useful, |
257 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
258 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
259 | + * GNU General Public License for more details. |
260 | + * |
261 | + * You should have received a copy of the GNU General Public License |
262 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
263 | + * |
264 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
265 | + */ |
266 | + |
267 | +#ifndef MIR_FRONTEND_SESSION_CREATOR_H_ |
268 | +#define MIR_FRONTEND_SESSION_CREATOR_H_ |
269 | + |
270 | +#include <boost/asio.hpp> |
271 | + |
272 | +#include <memory> |
273 | + |
274 | +namespace mir |
275 | +{ |
276 | +namespace frontend |
277 | +{ |
278 | +class SessionCreator |
279 | +{ |
280 | +public: |
281 | + virtual void create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket) = 0; |
282 | + |
283 | +protected: |
284 | + SessionCreator() = default; |
285 | + virtual ~SessionCreator() noexcept = default; |
286 | + SessionCreator(SessionCreator const&) = delete; |
287 | + SessionCreator& operator=(SessionCreator const&) = delete; |
288 | +}; |
289 | +} |
290 | +} |
291 | + |
292 | +#endif /* MIR_FRONTEND_SESSION_CREATOR_H_ */ |
293 | |
294 | === modified file 'include/server/mir/server_configuration.h' |
295 | --- include/server/mir/server_configuration.h 2013-09-18 21:09:29 +0000 |
296 | +++ include/server/mir/server_configuration.h 2013-09-25 14:20:36 +0000 |
297 | @@ -28,7 +28,7 @@ |
298 | } |
299 | namespace frontend |
300 | { |
301 | -class Communicator; |
302 | +class Connector; |
303 | class Shell; |
304 | } |
305 | namespace shell |
306 | @@ -57,7 +57,7 @@ |
307 | public: |
308 | // TODO most of these interfaces are wider DisplayServer needs... |
309 | // TODO ...some or all of them need narrowing |
310 | - virtual std::shared_ptr<frontend::Communicator> the_communicator() = 0; |
311 | + virtual std::shared_ptr<frontend::Connector> the_connector() = 0; |
312 | virtual std::shared_ptr<graphics::Display> the_display() = 0; |
313 | virtual std::shared_ptr<compositor::Compositor> the_compositor() = 0; |
314 | virtual std::shared_ptr<input::InputManager> the_input_manager() = 0; |
315 | |
316 | === modified file 'include/test/mir_test/test_protobuf_server.h' |
317 | --- include/test/mir_test/test_protobuf_server.h 2013-06-19 16:14:40 +0000 |
318 | +++ include/test/mir_test/test_protobuf_server.h 2013-09-25 14:20:36 +0000 |
319 | @@ -25,8 +25,8 @@ |
320 | { |
321 | namespace frontend |
322 | { |
323 | -class Communicator; |
324 | -class CommunicatorReport; |
325 | +class Connector; |
326 | +class ConnectorReport; |
327 | } |
328 | |
329 | namespace protobuf |
330 | @@ -45,10 +45,10 @@ |
331 | TestProtobufServer( |
332 | std::string const& socket_name, |
333 | std::shared_ptr<protobuf::DisplayServer> const& tool, |
334 | - std::shared_ptr<frontend::CommunicatorReport> const& report); |
335 | + std::shared_ptr<frontend::ConnectorReport> const& report); |
336 | |
337 | // "Server" side |
338 | - std::shared_ptr<frontend::Communicator> const comm; |
339 | + std::shared_ptr<frontend::Connector> const comm; |
340 | }; |
341 | } |
342 | } |
343 | |
344 | === modified file 'src/server/default_server_configuration.cpp' |
345 | --- src/server/default_server_configuration.cpp 2013-09-23 13:37:44 +0000 |
346 | +++ src/server/default_server_configuration.cpp 2013-09-25 14:20:36 +0000 |
347 | @@ -171,6 +171,7 @@ |
348 | }; |
349 | |
350 | char const* const server_socket_opt = "file"; |
351 | +char const* const no_server_socket_opt = "no-file"; |
352 | char const* const session_mediator_report_opt = "session-mediator-report"; |
353 | char const* const msg_processor_report_opt = "msg-processor-report"; |
354 | char const* const display_report_opt = "display-report"; |
355 | @@ -255,6 +256,7 @@ |
356 | "Host socket filename. [string:default={$MIR_SOCKET,/tmp/mir_socket}]") |
357 | ("file,f", po::value<std::string>(), |
358 | "Socket filename. [string:default=/tmp/mir_socket]") |
359 | + (no_server_socket_opt, "Do not provide a socket filename for client connections") |
360 | (platform_graphics_lib, po::value<std::string>(), |
361 | "Library to use for platform graphics support [default=libmirplatformgraphics.so]") |
362 | ("enable-input,i", po::value<bool>(), |
363 | |
364 | === modified file 'src/server/display_server.cpp' |
365 | --- src/server/display_server.cpp 2013-09-18 21:09:29 +0000 |
366 | +++ src/server/display_server.cpp 2013-09-25 14:20:36 +0000 |
367 | @@ -25,7 +25,7 @@ |
368 | #include "mir/display_changer.h" |
369 | |
370 | #include "mir/compositor/compositor.h" |
371 | -#include "mir/frontend/communicator.h" |
372 | +#include "mir/frontend/connector.h" |
373 | #include "mir/graphics/display.h" |
374 | #include "mir/input/input_manager.h" |
375 | |
376 | @@ -72,7 +72,7 @@ |
377 | display{config.the_display()}, |
378 | input_configuration{config.the_input_configuration()}, |
379 | compositor{config.the_compositor()}, |
380 | - communicator{config.the_communicator()}, |
381 | + connector{config.the_connector()}, |
382 | input_manager{config.the_input_manager()}, |
383 | main_loop{config.the_main_loop()}, |
384 | pause_resume_listener{config.the_pause_resume_listener()}, |
385 | @@ -103,8 +103,8 @@ |
386 | [this] { compositor->start(); }}; |
387 | |
388 | TryButRevertIfUnwinding comm{ |
389 | - [this] { communicator->stop(); }, |
390 | - [this] { communicator->start(); }}; |
391 | + [this] { connector->stop(); }, |
392 | + [this] { connector->start(); }}; |
393 | |
394 | display->pause(); |
395 | |
396 | @@ -129,8 +129,8 @@ |
397 | [this] { display->pause(); }}; |
398 | |
399 | TryButRevertIfUnwinding comm{ |
400 | - [this] { communicator->start(); }, |
401 | - [this] { communicator->stop(); }}; |
402 | + [this] { connector->start(); }, |
403 | + [this] { connector->stop(); }}; |
404 | |
405 | if (configure_display_on_resume) |
406 | { |
407 | @@ -176,7 +176,7 @@ |
408 | std::shared_ptr<mg::Display> const display; |
409 | std::shared_ptr<input::InputConfiguration> const input_configuration; |
410 | std::shared_ptr<mc::Compositor> const compositor; |
411 | - std::shared_ptr<mf::Communicator> const communicator; |
412 | + std::shared_ptr<mf::Connector> const connector; |
413 | std::shared_ptr<mi::InputManager> const input_manager; |
414 | std::shared_ptr<mir::MainLoop> const main_loop; |
415 | std::shared_ptr<mir::PauseResumeListener> const pause_resume_listener; |
416 | @@ -201,7 +201,7 @@ |
417 | |
418 | void mir::DisplayServer::run() |
419 | { |
420 | - p->communicator->start(); |
421 | + p->connector->start(); |
422 | p->compositor->start(); |
423 | p->input_manager->start(); |
424 | |
425 | @@ -209,7 +209,7 @@ |
426 | |
427 | p->input_manager->stop(); |
428 | p->compositor->stop(); |
429 | - p->communicator->stop(); |
430 | + p->connector->stop(); |
431 | } |
432 | |
433 | void mir::DisplayServer::stop() |
434 | |
435 | === modified file 'src/server/frontend/CMakeLists.txt' |
436 | --- src/server/frontend/CMakeLists.txt 2013-08-28 03:41:48 +0000 |
437 | +++ src/server/frontend/CMakeLists.txt 2013-09-25 14:20:36 +0000 |
438 | @@ -9,20 +9,19 @@ |
439 | protobuf_buffer_packer.cpp |
440 | null_message_processor.cpp |
441 | global_event_sender.cpp |
442 | - |
443 | + published_socket_connector.cpp |
444 | + protobuf_session_creator.cpp |
445 | + socket_session.cpp |
446 | resource_cache.cpp |
447 | socket_messenger.cpp |
448 | event_sender.cpp |
449 | surface.cpp |
450 | + |
451 | + default_configuration.cpp |
452 | + |
453 | ${PROTO_HDRS} |
454 | ) |
455 | |
456 | -list(APPEND FRONTEND_SOURCES |
457 | - protobuf_socket_communicator.cpp |
458 | - make_protobuf_socket_communicator.cpp |
459 | - socket_session.cpp |
460 | -) |
461 | - |
462 | if (MIR_PLATFORM STREQUAL "android") |
463 | list(APPEND FRONTEND_SOURCES session_mediator_android.cpp) |
464 | elseif (MIR_PLATFORM STREQUAL "gbm") |
465 | |
466 | === renamed file 'src/server/frontend/make_protobuf_socket_communicator.cpp' => 'src/server/frontend/default_configuration.cpp' |
467 | --- src/server/frontend/make_protobuf_socket_communicator.cpp 2013-08-28 03:41:48 +0000 |
468 | +++ src/server/frontend/default_configuration.cpp 2013-09-25 14:20:36 +0000 |
469 | @@ -17,39 +17,67 @@ |
470 | */ |
471 | |
472 | #include "mir/default_server_configuration.h" |
473 | +#include "protobuf_session_creator.h" |
474 | + |
475 | #include "mir/options/option.h" |
476 | #include "mir/frontend/shell.h" |
477 | #include "mir/shell/session_container.h" |
478 | #include "mir/shell/session.h" |
479 | -#include "protobuf_socket_communicator.h" |
480 | -#include "mir/frontend/communicator_report.h" |
481 | +#include "published_socket_connector.h" |
482 | +#include "mir/frontend/connector_report.h" |
483 | |
484 | namespace mf = mir::frontend; |
485 | -namespace mg = mir::graphics; |
486 | -namespace mc = mir::compositor; |
487 | namespace msh = mir::shell; |
488 | |
489 | -std::shared_ptr<mf::Communicator> |
490 | -mir::DefaultServerConfiguration::the_communicator() |
491 | -{ |
492 | - return communicator( |
493 | - [&,this]() -> std::shared_ptr<mf::Communicator> |
494 | +namespace |
495 | +{ |
496 | +char const* const no_server_socket_opt = "no-file"; |
497 | +} |
498 | + |
499 | +std::shared_ptr<mf::SessionCreator> |
500 | +mir::DefaultServerConfiguration::the_session_creator() |
501 | +{ |
502 | + return session_creator([this] |
503 | + { |
504 | + return std::make_shared<mf::ProtobufSessionCreator>( |
505 | + the_ipc_factory(the_frontend_shell(), the_buffer_allocator()), |
506 | + the_session_authorizer()); |
507 | + }); |
508 | +} |
509 | + |
510 | +std::shared_ptr<mf::Connector> |
511 | +mir::DefaultServerConfiguration::the_connector() |
512 | +{ |
513 | + return connector( |
514 | + [&,this]() -> std::shared_ptr<mf::Connector> |
515 | { |
516 | auto const threads = the_options()->get("ipc-thread-pool", 10); |
517 | auto shell_sessions = the_shell_session_container(); |
518 | - return std::make_shared<mf::ProtobufSocketCommunicator>( |
519 | - the_socket_file(), |
520 | - the_ipc_factory(the_frontend_shell(), the_buffer_allocator()), |
521 | - the_session_authorizer(), |
522 | - threads, |
523 | - [shell_sessions] |
524 | + auto const& force_requests_to_complete = [shell_sessions] |
525 | + { |
526 | + shell_sessions->for_each([](std::shared_ptr<msh::Session> const& session) |
527 | { |
528 | - shell_sessions->for_each([](std::shared_ptr<msh::Session> const& session) |
529 | - { |
530 | - session->force_requests_to_complete(); |
531 | - }); |
532 | - }, |
533 | - std::make_shared<mf::NullCommunicatorReport>()); |
534 | + session->force_requests_to_complete(); |
535 | + }); |
536 | + }; |
537 | + |
538 | + if (the_options()->is_set(no_server_socket_opt)) |
539 | + { |
540 | + return std::make_shared<mf::BasicConnector>( |
541 | + the_session_creator(), |
542 | + threads, |
543 | + force_requests_to_complete, |
544 | + std::make_shared<mf::NullConnectorReport>()); |
545 | + } |
546 | + else |
547 | + { |
548 | + return std::make_shared<mf::PublishedSocketConnector>( |
549 | + the_socket_file(), |
550 | + the_session_creator(), |
551 | + threads, |
552 | + force_requests_to_complete, |
553 | + std::make_shared<mf::NullConnectorReport>()); |
554 | + } |
555 | }); |
556 | } |
557 | |
558 | |
559 | === added file 'src/server/frontend/protobuf_session_creator.cpp' |
560 | --- src/server/frontend/protobuf_session_creator.cpp 1970-01-01 00:00:00 +0000 |
561 | +++ src/server/frontend/protobuf_session_creator.cpp 2013-09-25 14:20:36 +0000 |
562 | @@ -0,0 +1,73 @@ |
563 | +/* |
564 | + * Copyright © 2013 Canonical Ltd. |
565 | + * |
566 | + * This program is free software: you can redistribute it and/or modify it |
567 | + * under the terms of the GNU General Public License version 3, |
568 | + * as published by the Free Software Foundation. |
569 | + * |
570 | + * This program is distributed in the hope that it will be useful, |
571 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
572 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
573 | + * GNU General Public License for more details. |
574 | + * |
575 | + * You should have received a copy of the GNU General Public License |
576 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
577 | + * |
578 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
579 | + */ |
580 | + |
581 | +#include "protobuf_session_creator.h" |
582 | + |
583 | +#include "event_sender.h" |
584 | +#include "protobuf_message_processor.h" |
585 | +#include "socket_messenger.h" |
586 | +#include "socket_session.h" |
587 | + |
588 | +#include "mir/frontend/protobuf_ipc_factory.h" |
589 | +#include "mir/frontend/session_authorizer.h" |
590 | +#include "mir/protobuf/google_protobuf_guard.h" |
591 | + |
592 | +namespace mf = mir::frontend; |
593 | +namespace mfd = mir::frontend::detail; |
594 | +namespace ba = boost::asio; |
595 | + |
596 | +mf::ProtobufSessionCreator::ProtobufSessionCreator( |
597 | + std::shared_ptr<ProtobufIpcFactory> const& ipc_factory, |
598 | + std::shared_ptr<mf::SessionAuthorizer> const& session_authorizer) |
599 | +: ipc_factory(ipc_factory), |
600 | + session_authorizer(session_authorizer), |
601 | + next_session_id(0), |
602 | + connected_sessions(std::make_shared<mfd::ConnectedSessions<mfd::SocketSession>>()) |
603 | +{ |
604 | +} |
605 | + |
606 | +mf::ProtobufSessionCreator::~ProtobufSessionCreator() noexcept |
607 | +{ |
608 | + connected_sessions->clear(); |
609 | +} |
610 | + |
611 | +int mf::ProtobufSessionCreator::next_id() |
612 | +{ |
613 | + return next_session_id.fetch_add(1); |
614 | +} |
615 | + |
616 | +void mf::ProtobufSessionCreator::create_session_for(std::shared_ptr<ba::local::stream_protocol::socket> const& socket) |
617 | +{ |
618 | + auto const messenger = std::make_shared<detail::SocketMessenger>(socket); |
619 | + auto const client_pid = messenger->client_pid(); |
620 | + |
621 | + if (session_authorizer->connection_is_allowed(client_pid)) |
622 | + { |
623 | + auto const authorized_to_resize_display = session_authorizer->configure_display_is_allowed(client_pid); |
624 | + auto const event_sink = std::make_shared<detail::EventSender>(messenger); |
625 | + auto const msg_processor = std::make_shared<detail::ProtobufMessageProcessor>( |
626 | + messenger, |
627 | + ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display), |
628 | + ipc_factory->resource_cache(), |
629 | + ipc_factory->report()); |
630 | + |
631 | + const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor); |
632 | + connected_sessions->add(session); |
633 | + session->read_next_message(); |
634 | + } |
635 | +} |
636 | |
637 | === added file 'src/server/frontend/protobuf_session_creator.h' |
638 | --- src/server/frontend/protobuf_session_creator.h 1970-01-01 00:00:00 +0000 |
639 | +++ src/server/frontend/protobuf_session_creator.h 2013-09-25 14:20:36 +0000 |
640 | @@ -0,0 +1,60 @@ |
641 | +/* |
642 | + * Copyright © 2013 Canonical Ltd. |
643 | + * |
644 | + * This program is free software: you can redistribute it and/or modify it |
645 | + * under the terms of the GNU General Public License version 3, |
646 | + * as published by the Free Software Foundation. |
647 | + * |
648 | + * This program is distributed in the hope that it will be useful, |
649 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
650 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
651 | + * GNU General Public License for more details. |
652 | + * |
653 | + * You should have received a copy of the GNU General Public License |
654 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
655 | + * |
656 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
657 | + */ |
658 | + |
659 | +#ifndef MIR_FRONTEND_PROTOBUF_SESSION_CREATOR_H_ |
660 | +#define MIR_FRONTEND_PROTOBUF_SESSION_CREATOR_H_ |
661 | + |
662 | +#include "mir/frontend/session_creator.h" |
663 | +#include "connected_sessions.h" |
664 | + |
665 | +#include <atomic> |
666 | + |
667 | +namespace mir |
668 | +{ |
669 | +namespace frontend |
670 | +{ |
671 | +class ProtobufIpcFactory; |
672 | +class SessionAuthorizer; |
673 | + |
674 | +namespace detail |
675 | +{ |
676 | +struct SocketSession; |
677 | +} |
678 | + |
679 | +class ProtobufSessionCreator : public SessionCreator |
680 | +{ |
681 | +public: |
682 | + ProtobufSessionCreator( |
683 | + std::shared_ptr<ProtobufIpcFactory> const& ipc_factory, |
684 | + std::shared_ptr<SessionAuthorizer> const& session_authorizer); |
685 | + ~ProtobufSessionCreator() noexcept; |
686 | + |
687 | + void create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket); |
688 | + |
689 | +private: |
690 | + int next_id(); |
691 | + |
692 | + std::shared_ptr<ProtobufIpcFactory> const ipc_factory; |
693 | + std::shared_ptr<SessionAuthorizer> const session_authorizer; |
694 | + std::atomic<int> next_session_id; |
695 | + std::shared_ptr<detail::ConnectedSessions<detail::SocketSession>> const connected_sessions; |
696 | +}; |
697 | +} |
698 | +} |
699 | + |
700 | +#endif /* MIR_FRONTEND_PROTOBUF_SESSION_CREATOR_H_ */ |
701 | |
702 | === renamed file 'src/server/frontend/protobuf_socket_communicator.cpp' => 'src/server/frontend/published_socket_connector.cpp' |
703 | --- src/server/frontend/protobuf_socket_communicator.cpp 2013-08-28 03:41:48 +0000 |
704 | +++ src/server/frontend/published_socket_connector.cpp 2013-09-25 14:20:36 +0000 |
705 | @@ -16,67 +16,78 @@ |
706 | * Authored by: Thomas Guest <thomas.guest@canonical.com> |
707 | */ |
708 | |
709 | -#include "protobuf_socket_communicator.h" |
710 | -#include "protobuf_message_processor.h" |
711 | -#include "socket_session.h" |
712 | +#include "published_socket_connector.h" |
713 | +#include "protobuf_session_creator.h" |
714 | |
715 | -#include "mir/frontend/communicator_report.h" |
716 | -#include "mir/frontend/protobuf_ipc_factory.h" |
717 | -#include "mir/frontend/session_authorizer.h" |
718 | -#include "socket_messenger.h" |
719 | -#include "event_sender.h" |
720 | -#include "mir/protobuf/google_protobuf_guard.h" |
721 | +#include "mir/frontend/connector_report.h" |
722 | |
723 | #include <boost/signals2.hpp> |
724 | +#include <boost/exception/errinfo_errno.hpp> |
725 | +#include <boost/throw_exception.hpp> |
726 | + |
727 | +#include <sys/socket.h> |
728 | |
729 | namespace mf = mir::frontend; |
730 | namespace mfd = mir::frontend::detail; |
731 | namespace ba = boost::asio; |
732 | |
733 | -mf::ProtobufSocketCommunicator::ProtobufSocketCommunicator( |
734 | - std::string const& socket_file, |
735 | - std::shared_ptr<ProtobufIpcFactory> const& ipc_factory, |
736 | - std::shared_ptr<mf::SessionAuthorizer> const& session_authorizer, |
737 | +mf::PublishedSocketConnector::PublishedSocketConnector( |
738 | + const std::string& socket_file, |
739 | + std::shared_ptr<SessionCreator> const& session_creator, |
740 | int threads, |
741 | std::function<void()> const& force_requests_to_complete, |
742 | - std::shared_ptr<CommunicatorReport> const& report) |
743 | -: socket_file((std::remove(socket_file.c_str()), socket_file)), |
744 | - acceptor(io_service, socket_file), |
745 | - io_service_threads(threads), |
746 | - ipc_factory(ipc_factory), |
747 | - session_authorizer(session_authorizer), |
748 | - next_session_id(0), |
749 | - connected_sessions(std::make_shared<mfd::ConnectedSessions<mfd::SocketSession>>()), |
750 | - force_requests_to_complete(force_requests_to_complete), |
751 | - report(report) |
752 | + std::shared_ptr<ConnectorReport> const& report) |
753 | +: BasicConnector(session_creator, threads, force_requests_to_complete, report), |
754 | + socket_file(socket_file), |
755 | + acceptor(io_service, socket_file) |
756 | { |
757 | start_accept(); |
758 | } |
759 | |
760 | -void mf::ProtobufSocketCommunicator::start_accept() |
761 | +mf::PublishedSocketConnector::~PublishedSocketConnector() noexcept |
762 | +{ |
763 | + std::remove(socket_file.c_str()); |
764 | +} |
765 | + |
766 | +void mf::PublishedSocketConnector::start_accept() |
767 | { |
768 | auto socket = std::make_shared<boost::asio::local::stream_protocol::socket>(io_service); |
769 | |
770 | acceptor.async_accept( |
771 | *socket, |
772 | boost::bind( |
773 | - &ProtobufSocketCommunicator::on_new_connection, |
774 | + &PublishedSocketConnector::on_new_connection, |
775 | this, |
776 | socket, |
777 | ba::placeholders::error)); |
778 | } |
779 | |
780 | -int mf::ProtobufSocketCommunicator::next_id() |
781 | -{ |
782 | - int id = next_session_id.load(); |
783 | - while (!next_session_id.compare_exchange_weak(id, id + 1)) std::this_thread::yield(); |
784 | - return id; |
785 | -} |
786 | - |
787 | - |
788 | -void mf::ProtobufSocketCommunicator::start() |
789 | -{ |
790 | - auto run_io_service = [&] |
791 | +void mf::PublishedSocketConnector::on_new_connection( |
792 | + std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket, |
793 | + boost::system::error_code const& ec) |
794 | +{ |
795 | + if (!ec) |
796 | + { |
797 | + create_session_for(socket); |
798 | + } |
799 | + start_accept(); |
800 | +} |
801 | + |
802 | +mf::BasicConnector::BasicConnector( |
803 | + std::shared_ptr<SessionCreator> const& session_creator, |
804 | + int threads, |
805 | + std::function<void()> const& force_requests_to_complete, |
806 | + std::shared_ptr<ConnectorReport> const& report) |
807 | +: io_service_threads(threads), |
808 | + force_requests_to_complete(force_requests_to_complete), |
809 | + report(report), |
810 | + session_creator{session_creator} |
811 | +{ |
812 | +} |
813 | + |
814 | +void mf::BasicConnector::start() |
815 | +{ |
816 | + auto run_io_service = [this] |
817 | { |
818 | while (true) |
819 | try |
820 | @@ -92,16 +103,16 @@ |
821 | |
822 | for (auto& thread : io_service_threads) |
823 | { |
824 | - thread = std::move(std::thread(run_io_service)); |
825 | + thread = std::thread(run_io_service); |
826 | } |
827 | } |
828 | |
829 | -void mf::ProtobufSocketCommunicator::stop() |
830 | +void mf::BasicConnector::stop() |
831 | { |
832 | /* Stop processing new requests */ |
833 | io_service.stop(); |
834 | |
835 | - /* |
836 | + /* |
837 | * Ensure that any pending requests will complete (i.e., that they |
838 | * will not block indefinitely waiting for a resource from the server) |
839 | */ |
840 | @@ -120,44 +131,36 @@ |
841 | io_service.reset(); |
842 | } |
843 | |
844 | -mf::ProtobufSocketCommunicator::~ProtobufSocketCommunicator() |
845 | +void mf::BasicConnector::create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& server_socket) const |
846 | +{ |
847 | + session_creator->create_session_for(server_socket); |
848 | +} |
849 | + |
850 | +int mf::BasicConnector::client_socket_fd() const |
851 | +{ |
852 | + enum { server, client, size }; |
853 | + int socket_fd[size]; |
854 | + |
855 | + if (socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fd)) |
856 | + { |
857 | + BOOST_THROW_EXCEPTION( |
858 | + boost::enable_error_info( |
859 | + std::runtime_error("Could not create socket pair")) << boost::errinfo_errno(errno)); |
860 | + } |
861 | + |
862 | + auto const server_socket = std::make_shared<boost::asio::local::stream_protocol::socket>( |
863 | + io_service, boost::asio::local::stream_protocol(), socket_fd[server]); |
864 | + |
865 | + create_session_for(server_socket); |
866 | + |
867 | + return socket_fd[client]; |
868 | +} |
869 | + |
870 | +mf::BasicConnector::~BasicConnector() noexcept |
871 | { |
872 | stop(); |
873 | - |
874 | - connected_sessions->clear(); |
875 | - |
876 | - std::remove(socket_file.c_str()); |
877 | -} |
878 | - |
879 | -void mf::ProtobufSocketCommunicator::on_new_connection( |
880 | - std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket, |
881 | - boost::system::error_code const& ec) |
882 | -{ |
883 | - if (!ec) |
884 | - { |
885 | - auto messenger = std::make_shared<detail::SocketMessenger>(socket); |
886 | - auto client_pid = messenger->client_pid(); |
887 | - if (session_authorizer->connection_is_allowed(client_pid)) |
888 | - { |
889 | - auto authorized_to_resize_display = session_authorizer->configure_display_is_allowed(client_pid); |
890 | - auto event_sink = std::make_shared<detail::EventSender>(messenger); |
891 | - auto msg_processor = std::make_shared<detail::ProtobufMessageProcessor>( |
892 | - messenger, |
893 | - ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display), |
894 | - ipc_factory->resource_cache(), |
895 | - ipc_factory->report()); |
896 | - auto const& session = std::make_shared<mfd::SocketSession>( |
897 | - messenger, |
898 | - next_id(), |
899 | - connected_sessions, |
900 | - msg_processor); |
901 | - connected_sessions->add(session); |
902 | - session->read_next_message(); |
903 | - } |
904 | - } |
905 | - start_accept(); |
906 | -} |
907 | - |
908 | -void mf::NullCommunicatorReport::error(std::exception const& /*error*/) |
909 | +} |
910 | + |
911 | +void mf::NullConnectorReport::error(std::exception const& /*error*/) |
912 | { |
913 | } |
914 | |
915 | === renamed file 'src/server/frontend/protobuf_socket_communicator.h' => 'src/server/frontend/published_socket_connector.h' |
916 | --- src/server/frontend/protobuf_socket_communicator.h 2013-08-28 03:41:48 +0000 |
917 | +++ src/server/frontend/published_socket_connector.h 2013-09-25 14:20:36 +0000 |
918 | @@ -19,13 +19,10 @@ |
919 | #ifndef MIR_FRONTEND_PROTOBUF_ASIO_COMMUNICATOR_H_ |
920 | #define MIR_FRONTEND_PROTOBUF_ASIO_COMMUNICATOR_H_ |
921 | |
922 | -#include "connected_sessions.h" |
923 | - |
924 | -#include "mir/frontend/communicator.h" |
925 | +#include "mir/frontend/connector.h" |
926 | |
927 | #include <boost/asio.hpp> |
928 | |
929 | -#include <atomic> |
930 | #include <thread> |
931 | #include <string> |
932 | #include <vector> |
933 | @@ -43,52 +40,54 @@ |
934 | { |
935 | namespace frontend |
936 | { |
937 | -class ResourceCache; |
938 | -class ProtobufIpcFactory; |
939 | -class SessionAuthorizer; |
940 | - |
941 | -namespace detail |
942 | -{ |
943 | -struct SocketSession; |
944 | -class MessageSender; |
945 | -} |
946 | - |
947 | -class CommunicatorReport; |
948 | - |
949 | -class ProtobufSocketCommunicator : public Communicator |
950 | -{ |
951 | -public: |
952 | - // Create communicator based on Boost asio and Google protobufs |
953 | - // using the supplied socket. |
954 | - explicit ProtobufSocketCommunicator( |
955 | +class SessionCreator; |
956 | +class ConnectorReport; |
957 | + |
958 | +/// provides a client-side socket fd for each connection |
959 | +class BasicConnector : public Connector |
960 | +{ |
961 | +public: |
962 | + explicit BasicConnector( |
963 | + std::shared_ptr<SessionCreator> const& session_creator, |
964 | + int threads, |
965 | + std::function<void()> const& force_requests_to_complete, |
966 | + std::shared_ptr<ConnectorReport> const& report); |
967 | + ~BasicConnector() noexcept; |
968 | + void start() override; |
969 | + void stop() override; |
970 | + int client_socket_fd() const override; |
971 | + |
972 | +protected: |
973 | + void create_session_for(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& server_socket) const; |
974 | + boost::asio::io_service mutable io_service; |
975 | + |
976 | +private: |
977 | + std::vector<std::thread> io_service_threads; |
978 | + std::function<void()> const force_requests_to_complete; |
979 | + std::shared_ptr<ConnectorReport> const report; |
980 | + std::shared_ptr<SessionCreator> const session_creator; |
981 | +}; |
982 | + |
983 | +/// Accept connections over a published socket |
984 | +class PublishedSocketConnector : public BasicConnector |
985 | +{ |
986 | +public: |
987 | + explicit PublishedSocketConnector( |
988 | const std::string& socket_file, |
989 | - std::shared_ptr<ProtobufIpcFactory> const& ipc_factory, |
990 | - std::shared_ptr<SessionAuthorizer> const& session_authorizer, |
991 | + std::shared_ptr<SessionCreator> const& session_creator, |
992 | int threads, |
993 | std::function<void()> const& force_requests_to_complete, |
994 | - std::shared_ptr<CommunicatorReport> const& report); |
995 | - ~ProtobufSocketCommunicator(); |
996 | - void start(); |
997 | - void stop(); |
998 | + std::shared_ptr<ConnectorReport> const& report); |
999 | + ~PublishedSocketConnector() noexcept; |
1000 | |
1001 | private: |
1002 | void start_accept(); |
1003 | void on_new_connection(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket, |
1004 | boost::system::error_code const& ec); |
1005 | - int next_id(); |
1006 | |
1007 | const std::string socket_file; |
1008 | - boost::asio::io_service io_service; |
1009 | boost::asio::local::stream_protocol::acceptor acceptor; |
1010 | - std::vector<std::thread> io_service_threads; |
1011 | - std::shared_ptr<ProtobufIpcFactory> const ipc_factory; |
1012 | - std::shared_ptr<SessionAuthorizer> const session_authorizer; |
1013 | - std::atomic<int> next_session_id; |
1014 | - std::shared_ptr<detail::ConnectedSessions<detail::SocketSession>> const connected_sessions; |
1015 | - std::function<void()> const force_requests_to_complete; |
1016 | - std::shared_ptr<CommunicatorReport> const report; |
1017 | }; |
1018 | - |
1019 | } |
1020 | } |
1021 | |
1022 | |
1023 | === modified file 'src/server/frontend/socket_messenger.cpp' |
1024 | --- src/server/frontend/socket_messenger.cpp 2013-08-28 03:41:48 +0000 |
1025 | +++ src/server/frontend/socket_messenger.cpp 2013-09-25 14:20:36 +0000 |
1026 | @@ -59,7 +59,8 @@ |
1027 | // function has completed (if it would be executed asynchronously. |
1028 | // NOTE: we rely on this synchronous behavior as per the comment in |
1029 | // mf::SessionMediator::create_surface |
1030 | - ba::write(*socket, ba::buffer(whole_message)); |
1031 | + boost::system::error_code err; |
1032 | + ba::write(*socket, ba::buffer(whole_message), err); |
1033 | } |
1034 | |
1035 | void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds) |
1036 | |
1037 | === modified file 'tests/acceptance-tests/test_client_library.cpp' |
1038 | --- tests/acceptance-tests/test_client_library.cpp 2013-09-17 14:31:42 +0000 |
1039 | +++ tests/acceptance-tests/test_client_library.cpp 2013-09-25 14:20:36 +0000 |
1040 | @@ -22,7 +22,7 @@ |
1041 | #include "mir_toolkit/mir_client_library_debug.h" |
1042 | #include "src/client/client_buffer.h" |
1043 | |
1044 | -#include "mir/frontend/communicator.h" |
1045 | +#include "mir/frontend/connector.h" |
1046 | |
1047 | #include "mir_protobuf.pb.h" |
1048 | |
1049 | |
1050 | === modified file 'tests/acceptance-tests/test_server_shutdown.cpp' |
1051 | --- tests/acceptance-tests/test_server_shutdown.cpp 2013-09-17 14:31:42 +0000 |
1052 | +++ tests/acceptance-tests/test_server_shutdown.cpp 2013-09-25 14:20:36 +0000 |
1053 | @@ -326,19 +326,19 @@ |
1054 | */ |
1055 | std::weak_ptr<mir::graphics::Display> display = server_config->the_display(); |
1056 | std::weak_ptr<mir::compositor::Compositor> compositor = server_config->the_compositor(); |
1057 | - std::weak_ptr<mir::frontend::Communicator> communicator = server_config->the_communicator(); |
1058 | + std::weak_ptr<mir::frontend::Connector> connector = server_config->the_connector(); |
1059 | std::weak_ptr<mir::input::InputManager> input_manager = server_config->the_input_manager(); |
1060 | |
1061 | server_config.reset(); |
1062 | |
1063 | EXPECT_EQ(0, display.use_count()); |
1064 | EXPECT_EQ(0, compositor.use_count()); |
1065 | - EXPECT_EQ(0, communicator.use_count()); |
1066 | + EXPECT_EQ(0, connector.use_count()); |
1067 | EXPECT_EQ(0, input_manager.use_count()); |
1068 | |
1069 | if (display.use_count() != 0 || |
1070 | compositor.use_count() != 0 || |
1071 | - communicator.use_count() != 0 || |
1072 | + connector.use_count() != 0 || |
1073 | input_manager.use_count() != 0) |
1074 | { |
1075 | resources_freed_failure.set(); |
1076 | |
1077 | === modified file 'tests/acceptance-tests/test_test_framework.cpp' |
1078 | --- tests/acceptance-tests/test_test_framework.cpp 2013-04-24 05:22:20 +0000 |
1079 | +++ tests/acceptance-tests/test_test_framework.cpp 2013-09-25 14:20:36 +0000 |
1080 | @@ -18,7 +18,7 @@ |
1081 | |
1082 | #include "mir_test_framework/display_server_test_fixture.h" |
1083 | |
1084 | -#include "mir/frontend/communicator.h" |
1085 | +#include "mir/frontend/connector.h" |
1086 | |
1087 | #include <gmock/gmock.h> |
1088 | #include <gtest/gtest.h> |
1089 | |
1090 | === modified file 'tests/integration-tests/client/test_client_render.cpp' |
1091 | --- tests/integration-tests/client/test_client_render.cpp 2013-08-28 03:41:48 +0000 |
1092 | +++ tests/integration-tests/client/test_client_render.cpp 2013-09-25 14:20:36 +0000 |
1093 | @@ -27,7 +27,7 @@ |
1094 | #include "mir_test/stub_server_tool.h" |
1095 | #include "mir_test/test_protobuf_server.h" |
1096 | |
1097 | -#include "mir/frontend/communicator.h" |
1098 | +#include "mir/frontend/connector.h" |
1099 | |
1100 | #include <gmock/gmock.h> |
1101 | #include <thread> |
1102 | |
1103 | === modified file 'tests/integration-tests/shell/test_session.cpp' |
1104 | --- tests/integration-tests/shell/test_session.cpp 2013-08-28 03:41:48 +0000 |
1105 | +++ tests/integration-tests/shell/test_session.cpp 2013-09-25 14:20:36 +0000 |
1106 | @@ -29,7 +29,7 @@ |
1107 | #include "mir/surfaces/buffer_stream.h" |
1108 | #include "mir/compositor/renderer.h" |
1109 | #include "mir/compositor/renderer_factory.h" |
1110 | -#include "mir/frontend/communicator.h" |
1111 | +#include "mir/frontend/connector.h" |
1112 | |
1113 | #include "mir_test_doubles/stub_buffer.h" |
1114 | #include "mir_test_doubles/null_display.h" |
1115 | @@ -61,15 +61,16 @@ |
1116 | return input_configuration; |
1117 | } |
1118 | |
1119 | - std::shared_ptr<mf::Communicator> the_communicator() override |
1120 | + std::shared_ptr<mf::Connector> the_connector() override |
1121 | { |
1122 | - struct NullCommunicator : public mf::Communicator |
1123 | + struct NullConnector : public mf::Connector |
1124 | { |
1125 | void start() {} |
1126 | void stop() {} |
1127 | + int client_socket_fd() const override { return 0; } |
1128 | }; |
1129 | |
1130 | - return std::make_shared<NullCommunicator>(); |
1131 | + return std::make_shared<NullConnector>(); |
1132 | } |
1133 | |
1134 | std::shared_ptr<mg::GraphicBufferAllocator> the_buffer_allocator() override |
1135 | |
1136 | === modified file 'tests/integration-tests/test_display_server_main_loop_events.cpp' |
1137 | --- tests/integration-tests/test_display_server_main_loop_events.cpp 2013-09-18 21:09:29 +0000 |
1138 | +++ tests/integration-tests/test_display_server_main_loop_events.cpp 2013-09-25 14:20:36 +0000 |
1139 | @@ -17,7 +17,7 @@ |
1140 | */ |
1141 | |
1142 | #include "mir/compositor/compositor.h" |
1143 | -#include "mir/frontend/communicator.h" |
1144 | +#include "mir/frontend/connector.h" |
1145 | #include "mir/graphics/display_configuration.h" |
1146 | #include "mir/graphics/display_configuration_policy.h" |
1147 | #include "mir/main_loop.h" |
1148 | @@ -53,11 +53,12 @@ |
1149 | namespace |
1150 | { |
1151 | |
1152 | -class MockCommunicator : public mf::Communicator |
1153 | +class MockConnector : public mf::Connector |
1154 | { |
1155 | public: |
1156 | MOCK_METHOD0(start, void()); |
1157 | MOCK_METHOD0(stop, void()); |
1158 | + MOCK_CONST_METHOD0(client_socket_fd, int()); |
1159 | }; |
1160 | |
1161 | class MockDisplayChanger : public mir::DisplayChanger |
1162 | @@ -226,12 +227,12 @@ |
1163 | return mock_compositor; |
1164 | } |
1165 | |
1166 | - std::shared_ptr<mf::Communicator> the_communicator() override |
1167 | + std::shared_ptr<mf::Connector> the_connector() override |
1168 | { |
1169 | - if (!mock_communicator) |
1170 | - mock_communicator = std::make_shared<MockCommunicator>(); |
1171 | + if (!mock_connector) |
1172 | + mock_connector = std::make_shared<MockConnector>(); |
1173 | |
1174 | - return mock_communicator; |
1175 | + return mock_connector; |
1176 | } |
1177 | |
1178 | std::shared_ptr<mi::InputManager> the_input_manager() override |
1179 | @@ -262,10 +263,10 @@ |
1180 | return mock_compositor; |
1181 | } |
1182 | |
1183 | - std::shared_ptr<MockCommunicator> the_mock_communicator() |
1184 | + std::shared_ptr<MockConnector> the_mock_connector() |
1185 | { |
1186 | - the_communicator(); |
1187 | - return mock_communicator; |
1188 | + the_connector(); |
1189 | + return mock_connector; |
1190 | } |
1191 | |
1192 | std::shared_ptr<mtd::MockInputManager> the_mock_input_manager() |
1193 | @@ -304,7 +305,7 @@ |
1194 | private: |
1195 | std::shared_ptr<mtd::MockCompositor> mock_compositor; |
1196 | std::shared_ptr<MockDisplay> mock_display; |
1197 | - std::shared_ptr<MockCommunicator> mock_communicator; |
1198 | + std::shared_ptr<MockConnector> mock_connector; |
1199 | std::shared_ptr<mtd::MockInputManager> mock_input_manager; |
1200 | std::shared_ptr<MockDisplayChanger> mock_display_changer; |
1201 | |
1202 | @@ -410,33 +411,33 @@ |
1203 | |
1204 | auto mock_compositor = server_config.the_mock_compositor(); |
1205 | auto mock_display = server_config.the_mock_display(); |
1206 | - auto mock_communicator = server_config.the_mock_communicator(); |
1207 | + auto mock_connector = server_config.the_mock_connector(); |
1208 | auto mock_input_manager = server_config.the_mock_input_manager(); |
1209 | |
1210 | { |
1211 | InSequence s; |
1212 | |
1213 | /* Start */ |
1214 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1215 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1216 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1217 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1218 | |
1219 | /* Pause */ |
1220 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1221 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1222 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1223 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1224 | EXPECT_CALL(*mock_display, pause()).Times(1); |
1225 | |
1226 | /* Resume */ |
1227 | EXPECT_CALL(*mock_display, resume()).Times(1); |
1228 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1229 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1230 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1231 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1232 | |
1233 | /* Stop */ |
1234 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1235 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1236 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1237 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1238 | } |
1239 | |
1240 | mir::run_mir(server_config, |
1241 | @@ -461,27 +462,27 @@ |
1242 | |
1243 | auto mock_compositor = server_config.the_mock_compositor(); |
1244 | auto mock_display = server_config.the_mock_display(); |
1245 | - auto mock_communicator = server_config.the_mock_communicator(); |
1246 | + auto mock_connector = server_config.the_mock_connector(); |
1247 | auto mock_input_manager = server_config.the_mock_input_manager(); |
1248 | |
1249 | { |
1250 | InSequence s; |
1251 | |
1252 | /* Start */ |
1253 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1254 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1255 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1256 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1257 | |
1258 | /* Pause */ |
1259 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1260 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1261 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1262 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1263 | EXPECT_CALL(*mock_display, pause()).Times(1); |
1264 | |
1265 | /* Stop */ |
1266 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1267 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1268 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1269 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1270 | } |
1271 | |
1272 | mir::run_mir(server_config, |
1273 | @@ -505,33 +506,33 @@ |
1274 | |
1275 | auto mock_compositor = server_config.the_mock_compositor(); |
1276 | auto mock_display = server_config.the_mock_display(); |
1277 | - auto mock_communicator = server_config.the_mock_communicator(); |
1278 | + auto mock_connector = server_config.the_mock_connector(); |
1279 | auto mock_input_manager = server_config.the_mock_input_manager(); |
1280 | |
1281 | { |
1282 | InSequence s; |
1283 | |
1284 | /* Start */ |
1285 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1286 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1287 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1288 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1289 | |
1290 | /* Pause failure */ |
1291 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1292 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1293 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1294 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1295 | EXPECT_CALL(*mock_display, pause()) |
1296 | .WillOnce(Throw(std::runtime_error(""))); |
1297 | |
1298 | /* Attempt to continue */ |
1299 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1300 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1301 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1302 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1303 | |
1304 | /* Stop */ |
1305 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1306 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1307 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1308 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1309 | } |
1310 | |
1311 | mir::run_mir(server_config, |
1312 | @@ -555,7 +556,7 @@ |
1313 | |
1314 | auto mock_compositor = server_config.the_mock_compositor(); |
1315 | auto mock_display = server_config.the_mock_display(); |
1316 | - auto mock_communicator = server_config.the_mock_communicator(); |
1317 | + auto mock_connector = server_config.the_mock_connector(); |
1318 | auto mock_input_manager = server_config.the_mock_input_manager(); |
1319 | auto mock_display_changer = server_config.the_mock_display_changer(); |
1320 | |
1321 | @@ -563,7 +564,7 @@ |
1322 | InSequence s; |
1323 | |
1324 | /* Start */ |
1325 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1326 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1327 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1328 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1329 | |
1330 | @@ -575,7 +576,7 @@ |
1331 | /* Stop */ |
1332 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1333 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1334 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1335 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1336 | } |
1337 | |
1338 | mir::run_mir(server_config, |
1339 | @@ -599,7 +600,7 @@ |
1340 | |
1341 | auto mock_compositor = server_config.the_mock_compositor(); |
1342 | auto mock_display = server_config.the_mock_display(); |
1343 | - auto mock_communicator = server_config.the_mock_communicator(); |
1344 | + auto mock_connector = server_config.the_mock_connector(); |
1345 | auto mock_input_manager = server_config.the_mock_input_manager(); |
1346 | auto mock_display_changer = server_config.the_mock_display_changer(); |
1347 | |
1348 | @@ -607,19 +608,19 @@ |
1349 | InSequence s; |
1350 | |
1351 | /* Start */ |
1352 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1353 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1354 | EXPECT_CALL(*mock_compositor, start()).Times(1); |
1355 | EXPECT_CALL(*mock_input_manager, start()).Times(1); |
1356 | |
1357 | /* Pause event */ |
1358 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1359 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1360 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1361 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1362 | EXPECT_CALL(*mock_display, pause()) .Times(1); |
1363 | |
1364 | /* Resume and reconfigure event */ |
1365 | EXPECT_CALL(*mock_display, resume()).Times(1); |
1366 | - EXPECT_CALL(*mock_communicator, start()).Times(1); |
1367 | + EXPECT_CALL(*mock_connector, start()).Times(1); |
1368 | |
1369 | EXPECT_CALL(*mock_display_changer, |
1370 | configure_for_hardware_change(_, mir::DisplayChanger::RetainSystemState)) |
1371 | @@ -631,7 +632,7 @@ |
1372 | /* Stop */ |
1373 | EXPECT_CALL(*mock_input_manager, stop()).Times(1); |
1374 | EXPECT_CALL(*mock_compositor, stop()).Times(1); |
1375 | - EXPECT_CALL(*mock_communicator, stop()).Times(1); |
1376 | + EXPECT_CALL(*mock_connector, stop()).Times(1); |
1377 | } |
1378 | |
1379 | mir::run_mir(server_config, |
1380 | |
1381 | === modified file 'tests/integration-tests/test_error_reporting.cpp' |
1382 | --- tests/integration-tests/test_error_reporting.cpp 2013-08-28 03:41:48 +0000 |
1383 | +++ tests/integration-tests/test_error_reporting.cpp 2013-09-25 14:20:36 +0000 |
1384 | @@ -21,7 +21,7 @@ |
1385 | |
1386 | #include "mir/frontend/protobuf_ipc_factory.h" |
1387 | #include "mir/frontend/resource_cache.h" |
1388 | -#include "mir/frontend/communicator.h" |
1389 | +#include "mir/frontend/connector.h" |
1390 | |
1391 | #include "mir_protobuf.pb.h" |
1392 | |
1393 | |
1394 | === modified file 'tests/mir_test_doubles/test_protobuf_socket_server.cpp' |
1395 | --- tests/mir_test_doubles/test_protobuf_socket_server.cpp 2013-08-28 03:41:48 +0000 |
1396 | +++ tests/mir_test_doubles/test_protobuf_socket_server.cpp 2013-09-25 14:20:36 +0000 |
1397 | @@ -19,8 +19,9 @@ |
1398 | #include "mir_test/test_protobuf_server.h" |
1399 | #include "mir_test_doubles/stub_ipc_factory.h" |
1400 | #include "mir_test_doubles/stub_session_authorizer.h" |
1401 | -#include "mir/frontend/communicator_report.h" |
1402 | -#include "src/server/frontend/protobuf_socket_communicator.h" |
1403 | +#include "mir/frontend/connector_report.h" |
1404 | +#include "src/server/frontend/published_socket_connector.h" |
1405 | +#include "src/server/frontend/protobuf_session_creator.h" |
1406 | |
1407 | namespace mt = mir::test; |
1408 | namespace mtd = mir::test::doubles; |
1409 | @@ -28,15 +29,14 @@ |
1410 | |
1411 | namespace |
1412 | { |
1413 | -std::shared_ptr<mf::Communicator> make_communicator( |
1414 | +std::shared_ptr<mf::Connector> make_connector( |
1415 | std::string const& socket_name, |
1416 | std::shared_ptr<mf::ProtobufIpcFactory> const& factory, |
1417 | - std::shared_ptr<mf::CommunicatorReport> const& report) |
1418 | + std::shared_ptr<mf::ConnectorReport> const& report) |
1419 | { |
1420 | - return std::make_shared<mf::ProtobufSocketCommunicator>( |
1421 | + return std::make_shared<mf::PublishedSocketConnector>( |
1422 | socket_name, |
1423 | - factory, |
1424 | - std::make_shared<mtd::StubSessionAuthorizer>(), |
1425 | + std::make_shared<mf::ProtobufSessionCreator>(factory, std::make_shared<mtd::StubSessionAuthorizer>()), |
1426 | 10, |
1427 | []{}, |
1428 | report); |
1429 | @@ -46,14 +46,14 @@ |
1430 | mt::TestProtobufServer::TestProtobufServer( |
1431 | std::string const& socket_name, |
1432 | const std::shared_ptr<protobuf::DisplayServer>& tool) : |
1433 | - TestProtobufServer(socket_name, tool, std::make_shared<mf::NullCommunicatorReport>()) |
1434 | + TestProtobufServer(socket_name, tool, std::make_shared<mf::NullConnectorReport>()) |
1435 | { |
1436 | } |
1437 | |
1438 | mt::TestProtobufServer::TestProtobufServer( |
1439 | std::string const& socket_name, |
1440 | const std::shared_ptr<protobuf::DisplayServer>& tool, |
1441 | - std::shared_ptr<frontend::CommunicatorReport> const& report) : |
1442 | - comm(make_communicator(socket_name, std::make_shared<mtd::StubIpcFactory>(*tool), report)) |
1443 | + std::shared_ptr<frontend::ConnectorReport> const& report) : |
1444 | + comm(make_connector(socket_name, std::make_shared<mtd::StubIpcFactory>(*tool), report)) |
1445 | { |
1446 | } |
1447 | |
1448 | === modified file 'tests/unit-tests/client/test_client_mir_surface.cpp' |
1449 | --- tests/unit-tests/client/test_client_mir_surface.cpp 2013-08-28 03:41:48 +0000 |
1450 | +++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-09-25 14:20:36 +0000 |
1451 | @@ -30,7 +30,7 @@ |
1452 | #include "src/client/rpc/mir_basic_rpc_channel.h" |
1453 | |
1454 | #include "mir/frontend/resource_cache.h" |
1455 | -#include "mir/frontend/communicator.h" |
1456 | +#include "mir/frontend/connector.h" |
1457 | #include "mir/input/input_platform.h" |
1458 | #include "mir/input/input_receiver_thread.h" |
1459 | |
1460 | |
1461 | === modified file 'tests/unit-tests/frontend/CMakeLists.txt' |
1462 | --- tests/unit-tests/frontend/CMakeLists.txt 2013-08-28 03:41:48 +0000 |
1463 | +++ tests/unit-tests/frontend/CMakeLists.txt 2013-09-25 14:20:36 +0000 |
1464 | @@ -1,7 +1,7 @@ |
1465 | list(APPEND UNIT_TEST_SOURCES |
1466 | ${CMAKE_CURRENT_SOURCE_DIR}/test_client_buffer_tracker.cpp |
1467 | ${CMAKE_CURRENT_SOURCE_DIR}/stress_protobuf_communicator.cpp |
1468 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_communicator.cpp |
1469 | + ${CMAKE_CURRENT_SOURCE_DIR}/test_published_socket_connector.cpp |
1470 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_surface_apis.cpp |
1471 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_reports_errors.cpp |
1472 | ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_buffer_packer.cpp |
1473 | |
1474 | === modified file 'tests/unit-tests/frontend/stress_protobuf_communicator.cpp' |
1475 | --- tests/unit-tests/frontend/stress_protobuf_communicator.cpp 2013-08-28 03:41:48 +0000 |
1476 | +++ tests/unit-tests/frontend/stress_protobuf_communicator.cpp 2013-09-25 14:20:36 +0000 |
1477 | @@ -16,7 +16,7 @@ |
1478 | * Authored by: Alan Griffiths <alan@octopull.co.uk> |
1479 | */ |
1480 | |
1481 | -#include "mir/frontend/communicator.h" |
1482 | +#include "mir/frontend/connector.h" |
1483 | #include "mir/frontend/resource_cache.h" |
1484 | |
1485 | #include "mir_protobuf.pb.h" |
1486 | |
1487 | === modified file 'tests/unit-tests/frontend/test_protobuf_reports_errors.cpp' |
1488 | --- tests/unit-tests/frontend/test_protobuf_reports_errors.cpp 2013-06-19 16:14:40 +0000 |
1489 | +++ tests/unit-tests/frontend/test_protobuf_reports_errors.cpp 2013-09-25 14:20:36 +0000 |
1490 | @@ -17,7 +17,7 @@ |
1491 | * Alan Griffiths <alan@octopull.co.uk> |
1492 | */ |
1493 | |
1494 | -#include "mir/frontend/communicator.h" |
1495 | +#include "mir/frontend/connector.h" |
1496 | #include "mir/frontend/resource_cache.h" |
1497 | |
1498 | #include "mir_test/stub_server_tool.h" |
1499 | |
1500 | === modified file 'tests/unit-tests/frontend/test_protobuf_sends_fds.cpp' |
1501 | --- tests/unit-tests/frontend/test_protobuf_sends_fds.cpp 2013-06-03 08:14:01 +0000 |
1502 | +++ tests/unit-tests/frontend/test_protobuf_sends_fds.cpp 2013-09-25 14:20:36 +0000 |
1503 | @@ -17,7 +17,7 @@ |
1504 | * Alan Griffiths <alan@octopull.co.uk> |
1505 | */ |
1506 | |
1507 | -#include "mir/frontend/communicator.h" |
1508 | +#include "mir/frontend/connector.h" |
1509 | #include "mir/frontend/resource_cache.h" |
1510 | |
1511 | #include "mir_protobuf.pb.h" |
1512 | |
1513 | === modified file 'tests/unit-tests/frontend/test_protobuf_surface_apis.cpp' |
1514 | --- tests/unit-tests/frontend/test_protobuf_surface_apis.cpp 2013-06-03 08:14:01 +0000 |
1515 | +++ tests/unit-tests/frontend/test_protobuf_surface_apis.cpp 2013-09-25 14:20:36 +0000 |
1516 | @@ -17,7 +17,7 @@ |
1517 | * Alan Griffiths <alan@octopull.co.uk> |
1518 | */ |
1519 | |
1520 | -#include "mir/frontend/communicator.h" |
1521 | +#include "mir/frontend/connector.h" |
1522 | #include "mir/frontend/resource_cache.h" |
1523 | |
1524 | #include "mir_protobuf.pb.h" |
1525 | |
1526 | === renamed file 'tests/unit-tests/frontend/test_protobuf_communicator.cpp' => 'tests/unit-tests/frontend/test_published_socket_connector.cpp' |
1527 | --- tests/unit-tests/frontend/test_protobuf_communicator.cpp 2013-08-28 03:41:48 +0000 |
1528 | +++ tests/unit-tests/frontend/test_published_socket_connector.cpp 2013-09-25 14:20:36 +0000 |
1529 | @@ -17,10 +17,11 @@ |
1530 | * Alan Griffiths <alan@octopull.co.uk> |
1531 | */ |
1532 | |
1533 | -#include "mir/frontend/communicator.h" |
1534 | -#include "mir/frontend/communicator_report.h" |
1535 | +#include "mir/frontend/connector.h" |
1536 | +#include "mir/frontend/connector_report.h" |
1537 | #include "mir/frontend/resource_cache.h" |
1538 | -#include "src/server/frontend/protobuf_socket_communicator.h" |
1539 | +#include "src/server/frontend/published_socket_connector.h" |
1540 | +#include "src/server/frontend/protobuf_session_creator.h" |
1541 | |
1542 | #include "mir_protobuf.pb.h" |
1543 | |
1544 | @@ -45,7 +46,7 @@ |
1545 | |
1546 | namespace |
1547 | { |
1548 | -class MockCommunicatorReport : public mf::CommunicatorReport |
1549 | +class MockCommunicatorReport : public mf::ConnectorReport |
1550 | { |
1551 | public: |
1552 | |
1553 | @@ -55,20 +56,21 @@ |
1554 | }; |
1555 | } |
1556 | |
1557 | -struct ProtobufCommunicator : public ::testing::Test |
1558 | +struct PublishedSocketConnector : public ::testing::Test |
1559 | { |
1560 | static void SetUpTestCase() |
1561 | { |
1562 | + } |
1563 | + |
1564 | + void SetUp() |
1565 | + { |
1566 | communicator_report = std::make_shared<MockCommunicatorReport>(); |
1567 | stub_server_tool = std::make_shared<mt::StubServerTool>(); |
1568 | stub_server = std::make_shared<mt::TestProtobufServer>( |
1569 | "./test_socket", |
1570 | stub_server_tool, |
1571 | communicator_report); |
1572 | - } |
1573 | |
1574 | - void SetUp() |
1575 | - { |
1576 | using namespace testing; |
1577 | EXPECT_CALL(*communicator_report, error(_)).Times(AnyNumber()); |
1578 | stub_server->comm->start(); |
1579 | @@ -81,27 +83,27 @@ |
1580 | stub_server->comm->stop(); |
1581 | testing::Mock::VerifyAndClearExpectations(communicator_report.get()); |
1582 | client.reset(); |
1583 | - } |
1584 | |
1585 | - static void TearDownTestCase() |
1586 | - { |
1587 | stub_server.reset(); |
1588 | stub_server_tool.reset(); |
1589 | communicator_report.reset(); |
1590 | } |
1591 | |
1592 | + static void TearDownTestCase() |
1593 | + { |
1594 | + } |
1595 | + |
1596 | std::shared_ptr<mt::TestProtobufClient> client; |
1597 | static std::shared_ptr<MockCommunicatorReport> communicator_report; |
1598 | static std::shared_ptr<mt::StubServerTool> stub_server_tool; |
1599 | -private: |
1600 | static std::shared_ptr<mt::TestProtobufServer> stub_server; |
1601 | }; |
1602 | |
1603 | -std::shared_ptr<mt::StubServerTool> ProtobufCommunicator::stub_server_tool; |
1604 | -std::shared_ptr<MockCommunicatorReport> ProtobufCommunicator::communicator_report; |
1605 | -std::shared_ptr<mt::TestProtobufServer> ProtobufCommunicator::stub_server; |
1606 | +std::shared_ptr<mt::StubServerTool> PublishedSocketConnector::stub_server_tool; |
1607 | +std::shared_ptr<MockCommunicatorReport> PublishedSocketConnector::communicator_report; |
1608 | +std::shared_ptr<mt::TestProtobufServer> PublishedSocketConnector::stub_server; |
1609 | |
1610 | -TEST_F(ProtobufCommunicator, create_surface_results_in_a_callback) |
1611 | +TEST_F(PublishedSocketConnector, create_surface_results_in_a_callback) |
1612 | { |
1613 | EXPECT_CALL(*client, create_surface_done()).Times(1); |
1614 | |
1615 | @@ -114,7 +116,7 @@ |
1616 | client->wait_for_create_surface(); |
1617 | } |
1618 | |
1619 | -TEST_F(ProtobufCommunicator, connection_sets_app_name) |
1620 | +TEST_F(PublishedSocketConnector, connection_sets_app_name) |
1621 | { |
1622 | EXPECT_CALL(*client, connect_done()).Times(1); |
1623 | |
1624 | @@ -131,7 +133,7 @@ |
1625 | EXPECT_EQ(__PRETTY_FUNCTION__, stub_server_tool->app_name); |
1626 | } |
1627 | |
1628 | -TEST_F(ProtobufCommunicator, create_surface_sets_surface_name) |
1629 | +TEST_F(PublishedSocketConnector, create_surface_sets_surface_name) |
1630 | { |
1631 | EXPECT_CALL(*client, connect_done()).Times(1); |
1632 | EXPECT_CALL(*client, create_surface_done()).Times(1); |
1633 | @@ -160,7 +162,7 @@ |
1634 | } |
1635 | |
1636 | |
1637 | -TEST_F(ProtobufCommunicator, |
1638 | +TEST_F(PublishedSocketConnector, |
1639 | create_surface_results_in_a_surface_being_created) |
1640 | { |
1641 | EXPECT_CALL(*client, create_surface_done()).Times(1); |
1642 | @@ -184,7 +186,7 @@ |
1643 | |
1644 | } |
1645 | |
1646 | -TEST_F(ProtobufCommunicator, double_disconnection_attempt_throws_exception) |
1647 | +TEST_F(PublishedSocketConnector, double_disconnection_attempt_throws_exception) |
1648 | { |
1649 | using namespace testing; |
1650 | |
1651 | @@ -219,7 +221,7 @@ |
1652 | }, std::runtime_error); |
1653 | } |
1654 | |
1655 | -TEST_F(ProtobufCommunicator, getting_and_advancing_buffers) |
1656 | +TEST_F(PublishedSocketConnector, getting_and_advancing_buffers) |
1657 | { |
1658 | EXPECT_CALL(*client, create_surface_done()).Times(testing::AtLeast(0)); |
1659 | EXPECT_CALL(*client, disconnect_done()).Times(testing::AtLeast(0)); |
1660 | @@ -256,7 +258,7 @@ |
1661 | client->wait_for_disconnect_done(); |
1662 | } |
1663 | |
1664 | -TEST_F(ProtobufCommunicator, |
1665 | +TEST_F(PublishedSocketConnector, |
1666 | connect_create_surface_then_disconnect_a_session) |
1667 | { |
1668 | EXPECT_CALL(*client, create_surface_done()).Times(1); |
1669 | @@ -278,7 +280,7 @@ |
1670 | client->wait_for_disconnect_done(); |
1671 | } |
1672 | |
1673 | -TEST_F(ProtobufCommunicator, drm_auth_magic_is_processed_by_the_server) |
1674 | +TEST_F(PublishedSocketConnector, drm_auth_magic_is_processed_by_the_server) |
1675 | { |
1676 | mir::protobuf::DRMMagic magic; |
1677 | mir::protobuf::DRMAuthMagicStatus status; |
1678 | @@ -308,7 +310,7 @@ |
1679 | |
1680 | } |
1681 | |
1682 | -TEST_F(ProtobufCommunicator, forces_requests_to_complete_when_stopping) |
1683 | +TEST_F(PublishedSocketConnector, forces_requests_to_complete_when_stopping) |
1684 | { |
1685 | MockForceRequests mock_force_requests; |
1686 | auto stub_server_tool = std::make_shared<mt::StubServerTool>(); |
1687 | @@ -318,17 +320,18 @@ |
1688 | EXPECT_CALL(mock_force_requests, force_requests_to_complete()) |
1689 | .Times(2); |
1690 | |
1691 | - auto comms = std::make_shared<mf::ProtobufSocketCommunicator>( |
1692 | - "./test_socket1", ipc_factory, |
1693 | - std::make_shared<mtd::StubSessionAuthorizer>(), 10, |
1694 | - std::bind(&MockForceRequests::force_requests_to_complete, |
1695 | - &mock_force_requests), |
1696 | - std::make_shared<mf::NullCommunicatorReport>()); |
1697 | + auto comms = std::make_shared<mf::PublishedSocketConnector>( |
1698 | + "./test_socket1", |
1699 | + std::make_shared<mf::ProtobufSessionCreator>(ipc_factory, std::make_shared<mtd::StubSessionAuthorizer>()), |
1700 | + 10, |
1701 | + std::bind(&MockForceRequests::force_requests_to_complete, &mock_force_requests), |
1702 | + std::make_shared<mf::NullConnectorReport>()); |
1703 | + |
1704 | comms->start(); |
1705 | comms->stop(); |
1706 | } |
1707 | |
1708 | -TEST_F(ProtobufCommunicator, disorderly_disconnection_handled) |
1709 | +TEST_F(PublishedSocketConnector, disorderly_disconnection_handled) |
1710 | { |
1711 | using namespace testing; |
1712 | |
1713 | @@ -363,7 +366,7 @@ |
1714 | while (!done && cv.wait_until(lock, deadline) != std::cv_status::timeout); |
1715 | } |
1716 | |
1717 | -TEST_F(ProtobufCommunicator, configure_display) |
1718 | +TEST_F(PublishedSocketConnector, configure_display) |
1719 | { |
1720 | EXPECT_CALL(*client, display_configure_done()) |
1721 | .Times(1); |
1722 | @@ -376,3 +379,57 @@ |
1723 | |
1724 | client->wait_for_configure_display_done(); |
1725 | } |
1726 | + |
1727 | +TEST_F(PublishedSocketConnector, connection_using_socket_fd) |
1728 | +{ |
1729 | + int const next_buffer_calls{8}; |
1730 | + char buffer[128] = {0}; |
1731 | + sprintf(buffer, "fd://%d", stub_server->comm->client_socket_fd()); |
1732 | + auto client = std::make_shared<mt::TestProtobufClient>(buffer, 100); |
1733 | + client->connect_parameters.set_application_name(__PRETTY_FUNCTION__); |
1734 | + |
1735 | + EXPECT_CALL(*client, connect_done()).Times(1); |
1736 | + |
1737 | + client->display_server.connect( |
1738 | + 0, |
1739 | + &client->connect_parameters, |
1740 | + &client->connection, |
1741 | + google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::connect_done)); |
1742 | + |
1743 | + EXPECT_CALL(*client, create_surface_done()).Times(testing::AtLeast(0)); |
1744 | + EXPECT_CALL(*client, disconnect_done()).Times(testing::AtLeast(0)); |
1745 | + |
1746 | + client->display_server.create_surface( |
1747 | + 0, |
1748 | + &client->surface_parameters, |
1749 | + &client->surface, |
1750 | + google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::create_surface_done)); |
1751 | + |
1752 | + client->wait_for_create_surface(); |
1753 | + |
1754 | + EXPECT_TRUE(client->surface.has_buffer()); |
1755 | + EXPECT_CALL(*client, next_buffer_done()).Times(next_buffer_calls); |
1756 | + |
1757 | + for (int i = 0; i != next_buffer_calls; ++i) |
1758 | + { |
1759 | + client->display_server.next_buffer( |
1760 | + 0, |
1761 | + &client->surface.id(), |
1762 | + client->surface.mutable_buffer(), |
1763 | + google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::next_buffer_done)); |
1764 | + |
1765 | + client->wait_for_next_buffer(); |
1766 | + EXPECT_TRUE(client->surface.has_buffer()); |
1767 | + } |
1768 | + |
1769 | + client->display_server.disconnect( |
1770 | + 0, |
1771 | + &client->ignored, |
1772 | + &client->ignored, |
1773 | + google::protobuf::NewCallback(client.get(), &mt::TestProtobufClient::disconnect_done)); |
1774 | + |
1775 | + client->wait_for_disconnect_done(); |
1776 | + |
1777 | + EXPECT_EQ(__PRETTY_FUNCTION__, stub_server_tool->app_name); |
1778 | +} |
1779 | + |
FAILED: Continuous integration, rev:1099 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- ci/3/ jenkins. qa.ubuntu. com/job/ mir-android- saucy-i386- build/2103 jenkins. qa.ubuntu. com/job/ mir-clang- saucy-amd64- build/1988 jenkins. qa.ubuntu. com/job/ mir-team- mir-development -branch- saucy-amd64- ci/3/console
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ mir-team- mir-development -branch- ci/3/rebuild
http://