Mir

Merge lp:~robertcarr/mir/socket-messenger-reporting into lp:mir

Proposed by Robert Carr
Status: Superseded
Proposed branch: lp:~robertcarr/mir/socket-messenger-reporting
Merge into: lp:mir
Diff against target: 573 lines (+279/-13)
17 files modified
debian/changelog (+8/-2)
include/server/mir/default_server_configuration.h (+3/-0)
include/server/mir/frontend/connector_report.h (+0/-1)
include/server/mir/frontend/messenger_report.h (+49/-0)
include/server/mir/frontend/protobuf_ipc_factory.h (+3/-1)
include/server/mir/logging/messenger_report.h (+49/-0)
include/test/mir_test_doubles/stub_ipc_factory.h (+6/-1)
src/server/default_server_configuration.cpp (+31/-3)
src/server/frontend/CMakeLists.txt (+1/-0)
src/server/frontend/null_messenger_report.cpp (+25/-0)
src/server/frontend/protobuf_session_creator.cpp (+2/-2)
src/server/frontend/socket_messenger.cpp (+11/-2)
src/server/frontend/socket_messenger.h (+6/-1)
src/server/logging/CMakeLists.txt (+1/-0)
src/server/logging/messenger_report.cpp (+46/-0)
tests/unit-tests/frontend/CMakeLists.txt (+1/-0)
tests/unit-tests/frontend/test_socket_messenger.cpp (+37/-0)
To merge this branch: bzr merge lp:~robertcarr/mir/socket-messenger-reporting
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Alan Griffiths Needs Fixing
Daniel van Vugt Pending
Review via email: mp+187822@code.launchpad.net

This proposal supersedes a proposal from 2013-09-23.

This proposal has been superseded by a proposal from 2013-09-26.

Commit message

Add messenger report and report socket messenger write errors.

Description of the change

Report socket messenger write errors so we can keep track of this.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

[ try]
9 {
50 ba::write(*socket, ba::buffer(whole_message));
51 }
52 - catch (std::exception &)
53 + catch (std::exception &ex)
54 {
55 - // Don't care
56 + report->error(ex);
57 }

This is better written as:

    boost::system::error_code ec;
    ba::write(*socket, ba::buffer(whole_message), ec);

    if (!ec)
    {
        report->error(ec.message());
    }

And not throwing and catching exceptions.

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal

Fixed to use the error code, updating to trunk with the reorganization of some frontend interfaces (notably communicator_report->connector_report) made it necessary to introduce a new reporting interface. messenger_report

Revision history for this message
Robert Carr (robertcarr) wrote :

Branch confusion....

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

418 + if (!err)

Sorry, my typo - there should be no "!"! (Shouldn't a test detect this is wrong?)

And what is the deal with debian/changelog?

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1077. By Robert Carr

Merge development branch

Unmerged revisions

1077. By Robert Carr

Merge development branch

1076. By Robert Carr

Update tests

1075. By Robert Carr

Merge trunk and update to new frontend interfaces

1074. By Robert Carr

Typo

1073. By Robert Carr

socket_messenger: Report exceptions

1072. By Daniel van Vugt

Stop asio::write from throwing exceptions (SIGPIPE). It will only do so
after we've closed the socket, at which point we don't really care.
(LP: #1226139)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-09-26 02:41:07 +0000
3+++ debian/changelog 2013-09-26 19:15:16 +0000
4@@ -1,4 +1,4 @@
5-mir (0.0.12-0ubuntu1) UNRELEASED; urgency=low
6+mir (0.0.12+13.10.20130926.1-0ubuntu1) saucy; urgency=low
7
8 [ kg ]
9 * bump version for ABI break (LP: #1229212)
10@@ -6,7 +6,13 @@
11 [ Robert Ancell ]
12 * Bump version to 0.0.12
13
14- -- Robert Ancell <robert.ancell@canonical.com> Thu, 26 Sep 2013 09:34:23 +1200
15+ [ Alexandros Frantzis ]
16+ * tests: Fix compiler warning about maybe-uninitialized struct member
17+
18+ [ Ubuntu daily release ]
19+ * Automatic snapshot from revision 1084
20+
21+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 26 Sep 2013 08:39:29 +0000
22
23 mir (0.0.11+13.10.20130924.1-0ubuntu1) saucy; urgency=low
24
25
26=== modified file 'include/server/mir/default_server_configuration.h'
27--- include/server/mir/default_server_configuration.h 2013-09-24 11:43:27 +0000
28+++ include/server/mir/default_server_configuration.h 2013-09-26 19:15:16 +0000
29@@ -46,6 +46,7 @@
30 class SessionCreator;
31 class SessionMediatorReport;
32 class MessageProcessorReport;
33+class MessengerReport;
34 class SessionAuthorizer;
35 class EventSink;
36 class DisplayChanger;
37@@ -165,6 +166,7 @@
38 * @{ */
39 virtual std::shared_ptr<frontend::SessionMediatorReport> the_session_mediator_report();
40 virtual std::shared_ptr<frontend::MessageProcessorReport> the_message_processor_report();
41+ virtual std::shared_ptr<frontend::MessengerReport> the_messenger_report();
42 virtual std::shared_ptr<frontend::SessionAuthorizer> the_session_authorizer();
43 virtual std::shared_ptr<frontend::Shell> the_frontend_shell();
44 virtual std::shared_ptr<frontend::EventSink> the_global_event_sink();
45@@ -270,6 +272,7 @@
46 CachedPtr<frontend::ProtobufIpcFactory> ipc_factory;
47 CachedPtr<frontend::SessionMediatorReport> session_mediator_report;
48 CachedPtr<frontend::MessageProcessorReport> message_processor_report;
49+ CachedPtr<frontend::MessengerReport> messenger_report;
50 CachedPtr<frontend::SessionAuthorizer> session_authorizer;
51 CachedPtr<frontend::EventSink> global_event_sink;
52 CachedPtr<frontend::SessionCreator> session_creator;
53
54=== modified file 'include/server/mir/frontend/connector_report.h'
55--- include/server/mir/frontend/connector_report.h 2013-09-24 16:20:17 +0000
56+++ include/server/mir/frontend/connector_report.h 2013-09-26 19:15:16 +0000
57@@ -42,7 +42,6 @@
58 class NullConnectorReport : public ConnectorReport
59 {
60 public:
61-
62 void error(std::exception const& error);
63 };
64 }
65
66=== added file 'include/server/mir/frontend/messenger_report.h'
67--- include/server/mir/frontend/messenger_report.h 1970-01-01 00:00:00 +0000
68+++ include/server/mir/frontend/messenger_report.h 2013-09-26 19:15:16 +0000
69@@ -0,0 +1,49 @@
70+/*
71+ * Copyright © 2013 Canonical Ltd.
72+ *
73+ * This program is free software: you can redistribute it and/or modify it
74+ * under the terms of the GNU General Public License version 3,
75+ * as published by the Free Software Foundation.
76+ *
77+ * This program is distributed in the hope that it will be useful,
78+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
79+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80+ * GNU General Public License for more details.
81+ *
82+ * You should have received a copy of the GNU General Public License
83+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
84+ *
85+ * Authored by: Robert Carr <robert.carr@canonical.com>
86+ */
87+
88+#ifndef MIR_FRONTEND_MESSENGER_REPORT_H_
89+#define MIR_FRONTEND_MESSENGER_REPORT_H_
90+
91+#include <string>
92+
93+namespace mir
94+{
95+namespace frontend
96+{
97+
98+class MessengerReport
99+{
100+public:
101+ virtual void error(std::string const& error_message) = 0;
102+
103+protected:
104+ virtual ~MessengerReport() = default;
105+ MessengerReport() = default;
106+ MessengerReport(const MessengerReport&) = delete;
107+ MessengerReport& operator=(const MessengerReport&) = delete;
108+};
109+
110+class NullMessengerReport : public MessengerReport
111+{
112+public:
113+ void error(std::string const& error_message);
114+};
115+}
116+}
117+
118+#endif // MIR_FRONTEND_MESSENGER_REPORT_H_
119
120=== modified file 'include/server/mir/frontend/protobuf_ipc_factory.h'
121--- include/server/mir/frontend/protobuf_ipc_factory.h 2013-08-28 03:41:48 +0000
122+++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-09-26 19:15:16 +0000
123@@ -32,6 +32,7 @@
124 class EventSink;
125 class ResourceCache;
126 class MessageProcessorReport;
127+class MessengerReport;
128
129 class ProtobufIpcFactory
130 {
131@@ -39,7 +40,8 @@
132 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
133 std::shared_ptr<EventSink> const& sink, bool authorized_to_resize_display) = 0;
134 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;
135- virtual std::shared_ptr<MessageProcessorReport> report() = 0;
136+ virtual std::shared_ptr<MessageProcessorReport> message_processor_report() = 0;
137+ virtual std::shared_ptr<MessengerReport> messenger_report() = 0;
138
139 protected:
140 ProtobufIpcFactory() {}
141
142=== added file 'include/server/mir/logging/messenger_report.h'
143--- include/server/mir/logging/messenger_report.h 1970-01-01 00:00:00 +0000
144+++ include/server/mir/logging/messenger_report.h 2013-09-26 19:15:16 +0000
145@@ -0,0 +1,49 @@
146+/*
147+ * Copyright © 2013 Canonical Ltd.
148+ *
149+ * This program is free software: you can redistribute it and/or modify it
150+ * under the terms of the GNU General Public License version 3,
151+ * as published by the Free Software Foundation.
152+ *
153+ * This program is distributed in the hope that it will be useful,
154+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
155+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
156+ * GNU General Public License for more details.
157+ *
158+ * You should have received a copy of the GNU General Public License
159+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
160+ *
161+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
162+ */
163+
164+#ifndef MIR_LOGGING_MESSENGER_REPORT_H_
165+#define MIR_LOGGING_MESSENGER_REPORT_H_
166+
167+#include "mir/frontend/messenger_report.h"
168+
169+#include <memory>
170+
171+namespace mir
172+{
173+namespace logging
174+{
175+class Logger;
176+
177+class MessengerReport : public frontend::MessengerReport
178+{
179+public:
180+ MessengerReport(std::shared_ptr<Logger> const& logger);
181+ virtual ~MessengerReport() noexcept(true) = default;
182+
183+ void error(std::string const& error_message);
184+
185+private:
186+ char const* component();
187+ std::shared_ptr<Logger> const logger;
188+};
189+
190+}
191+}
192+
193+
194+#endif /* MIR_LOGGING_MESSENGER_REPORT_H_ */
195
196=== modified file 'include/test/mir_test_doubles/stub_ipc_factory.h'
197--- include/test/mir_test_doubles/stub_ipc_factory.h 2013-08-28 03:41:48 +0000
198+++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-09-26 19:15:16 +0000
199@@ -24,6 +24,7 @@
200 #include "mir/frontend/protobuf_ipc_factory.h"
201 #include "mir/frontend/resource_cache.h"
202 #include "mir/frontend/null_message_processor_report.h"
203+#include "mir/frontend/messenger_report.h"
204
205 namespace mir
206 {
207@@ -53,10 +54,14 @@
208 return cache;
209 }
210
211- virtual std::shared_ptr<frontend::MessageProcessorReport> report()
212+ virtual std::shared_ptr<frontend::MessageProcessorReport> message_processor_report()
213 {
214 return std::make_shared<frontend::NullMessageProcessorReport>();
215 }
216+ virtual std::shared_ptr<frontend::MessengerReport> messenger_report()
217+ {
218+ return std::make_shared<frontend::NullMessengerReport>();
219+ }
220
221 std::shared_ptr<protobuf::DisplayServer> server;
222 std::shared_ptr<frontend::ResourceCache> const cache;
223
224=== modified file 'src/server/default_server_configuration.cpp'
225--- src/server/default_server_configuration.cpp 2013-09-24 17:25:47 +0000
226+++ src/server/default_server_configuration.cpp 2013-09-26 19:15:16 +0000
227@@ -30,6 +30,7 @@
228 #include "mir/frontend/protobuf_ipc_factory.h"
229 #include "mir/frontend/session_mediator_report.h"
230 #include "mir/frontend/null_message_processor_report.h"
231+#include "mir/frontend/messenger_report.h"
232 #include "mir/frontend/session_mediator.h"
233 #include "mir/frontend/session_authorizer.h"
234 #include "mir/frontend/global_event_sender.h"
235@@ -75,6 +76,7 @@
236 #include "mir/logging/session_mediator_report.h"
237 #include "mir/logging/message_processor_report.h"
238 #include "mir/logging/display_report.h"
239+#include "mir/logging/messenger_report.h"
240 #include "mir/lttng/message_processor_report.h"
241 #include "mir/lttng/input_report.h"
242 #include "mir/shell/surface_source.h"
243@@ -113,13 +115,15 @@
244 explicit DefaultIpcFactory(
245 std::shared_ptr<mf::Shell> const& shell,
246 std::shared_ptr<mf::SessionMediatorReport> const& sm_report,
247- std::shared_ptr<mf::MessageProcessorReport> const& mr_report,
248+ std::shared_ptr<mf::MessageProcessorReport> const& mp_report,
249+ std::shared_ptr<mf::MessengerReport> const& messenger_report,
250 std::shared_ptr<mg::Platform> const& graphics_platform,
251 std::shared_ptr<mf::DisplayChanger> const& display_changer,
252 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator) :
253 shell(shell),
254 sm_report(sm_report),
255- mp_report(mr_report),
256+ mp_report(mp_report),
257+ msger_report(messenger_report),
258 cache(std::make_shared<mf::ResourceCache>()),
259 graphics_platform(graphics_platform),
260 display_changer(display_changer),
261@@ -131,6 +135,7 @@
262 std::shared_ptr<mf::Shell> shell;
263 std::shared_ptr<mf::SessionMediatorReport> const sm_report;
264 std::shared_ptr<mf::MessageProcessorReport> const mp_report;
265+ std::shared_ptr<mf::MessengerReport> const msger_report;
266 std::shared_ptr<mf::ResourceCache> const cache;
267 std::shared_ptr<mg::Platform> const graphics_platform;
268 std::shared_ptr<mf::DisplayChanger> const display_changer;
269@@ -164,16 +169,21 @@
270 return cache;
271 }
272
273- virtual std::shared_ptr<mf::MessageProcessorReport> report()
274+ virtual std::shared_ptr<mf::MessageProcessorReport> message_processor_report()
275 {
276 return mp_report;
277 }
278+ virtual std::shared_ptr<mf::MessengerReport> messenger_report()
279+ {
280+ return msger_report;
281+ }
282 };
283
284 char const* const server_socket_opt = "file";
285 char const* const no_server_socket_opt = "no-file";
286 char const* const session_mediator_report_opt = "session-mediator-report";
287 char const* const msg_processor_report_opt = "msg-processor-report";
288+char const* const messenger_report_opt = "messenger-report";
289 char const* const display_report_opt = "display-report";
290 char const* const legacy_input_report_opt = "legacy-input-report";
291 char const* const input_report_opt = "input-report";
292@@ -824,6 +834,7 @@
293 shell,
294 the_session_mediator_report(),
295 the_message_processor_report(),
296+ the_messenger_report(),
297 the_graphics_platform(),
298 the_frontend_display_changer(), allocator);
299 });
300@@ -890,6 +901,23 @@
301 });
302 }
303
304+std::shared_ptr<mf::MessengerReport>
305+mir::DefaultServerConfiguration::the_messenger_report()
306+{
307+ return messenger_report(
308+ [this]() -> std::shared_ptr<mf::MessengerReport>
309+ {
310+ auto report_opt = the_options()->get(messenger_report_opt, off_opt_value);
311+ if (report_opt == log_opt_value)
312+ {
313+ return std::make_shared<ml::MessengerReport>(the_logger());
314+ }
315+ else
316+ {
317+ return std::make_shared<mf::NullMessengerReport>();
318+ }
319+ });
320+}
321
322 std::shared_ptr<ml::Logger> mir::DefaultServerConfiguration::the_logger()
323 {
324
325=== modified file 'src/server/frontend/CMakeLists.txt'
326--- src/server/frontend/CMakeLists.txt 2013-09-24 13:27:33 +0000
327+++ src/server/frontend/CMakeLists.txt 2013-09-26 19:15:16 +0000
328@@ -5,6 +5,7 @@
329 session_mediator.cpp
330 null_session_mediator_report.cpp
331 null_message_processor_report.cpp
332+ null_messenger_report.cpp
333 protobuf_message_processor.cpp
334 protobuf_buffer_packer.cpp
335 null_message_processor.cpp
336
337=== added file 'src/server/frontend/null_messenger_report.cpp'
338--- src/server/frontend/null_messenger_report.cpp 1970-01-01 00:00:00 +0000
339+++ src/server/frontend/null_messenger_report.cpp 2013-09-26 19:15:16 +0000
340@@ -0,0 +1,25 @@
341+/*
342+ * Copyright © 2013 Canonical Ltd.
343+ *
344+ * This program is free software: you can redistribute it and/or modify it
345+ * under the terms of the GNU General Public License version 3,
346+ * as published by the Free Software Foundation.
347+ *
348+ * This program is distributed in the hope that it will be useful,
349+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
350+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
351+ * GNU General Public License for more details.
352+ *
353+ * You should have received a copy of the GNU General Public License
354+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
355+ *
356+ * Authored by: Robert Carr <robert.carr@canonical.com>
357+ */
358+
359+#include "mir/frontend/messenger_report.h"
360+
361+namespace mf = mir::frontend;
362+
363+void mf::NullMessengerReport::error(std::string const&)
364+{
365+}
366
367=== modified file 'src/server/frontend/protobuf_session_creator.cpp'
368--- src/server/frontend/protobuf_session_creator.cpp 2013-09-24 13:27:33 +0000
369+++ src/server/frontend/protobuf_session_creator.cpp 2013-09-26 19:15:16 +0000
370@@ -53,7 +53,7 @@
371
372 void mf::ProtobufSessionCreator::create_session_for(std::shared_ptr<ba::local::stream_protocol::socket> const& socket)
373 {
374- auto const messenger = std::make_shared<detail::SocketMessenger>(socket);
375+ auto const messenger = std::make_shared<detail::SocketMessenger>(socket, ipc_factory->messenger_report());
376 auto const client_pid = messenger->client_pid();
377
378 if (session_authorizer->connection_is_allowed(client_pid))
379@@ -64,7 +64,7 @@
380 messenger,
381 ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display),
382 ipc_factory->resource_cache(),
383- ipc_factory->report());
384+ ipc_factory->message_processor_report());
385
386 const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor);
387 connected_sessions->add(session);
388
389=== modified file 'src/server/frontend/socket_messenger.cpp'
390--- src/server/frontend/socket_messenger.cpp 2013-09-25 14:18:18 +0000
391+++ src/server/frontend/socket_messenger.cpp 2013-09-26 19:15:16 +0000
392@@ -18,13 +18,16 @@
393
394 #include "socket_messenger.h"
395 #include "mir/frontend/client_constants.h"
396+#include "mir/frontend/messenger_report.h"
397
398 namespace mfd = mir::frontend::detail;
399 namespace bs = boost::system;
400 namespace ba = boost::asio;
401
402-mfd::SocketMessenger::SocketMessenger(std::shared_ptr<ba::local::stream_protocol::socket> const& socket)
403- : socket(socket)
404+mfd::SocketMessenger::SocketMessenger(std::shared_ptr<ba::local::stream_protocol::socket> const& socket,
405+ std::shared_ptr<MessengerReport> const& report)
406+ : socket(socket),
407+ report(report)
408 {
409 whole_message.reserve(serialization_buffer_size);
410 }
411@@ -59,8 +62,14 @@
412 // function has completed (if it would be executed asynchronously.
413 // NOTE: we rely on this synchronous behavior as per the comment in
414 // mf::SessionMediator::create_surface
415+
416 boost::system::error_code err;
417 ba::write(*socket, ba::buffer(whole_message), err);
418+ if (!err)
419+ {
420+ report->error(err.message());
421+ }
422+
423 }
424
425 void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds)
426
427=== modified file 'src/server/frontend/socket_messenger.h'
428--- src/server/frontend/socket_messenger.h 2013-08-28 03:41:48 +0000
429+++ src/server/frontend/socket_messenger.h 2013-09-26 19:15:16 +0000
430@@ -26,13 +26,16 @@
431 {
432 namespace frontend
433 {
434+class MessengerReport;
435+
436 namespace detail
437 {
438 class SocketMessenger : public MessageSender,
439 public MessageReceiver
440 {
441 public:
442- SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket);
443+ SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket,
444+ std::shared_ptr<frontend::MessengerReport> const& report);
445
446 void send(std::string const& body);
447 void send_fds(std::vector<int32_t> const& fds);
448@@ -42,6 +45,8 @@
449
450 private:
451 std::shared_ptr<boost::asio::local::stream_protocol::socket> socket;
452+ std::shared_ptr<MessengerReport> const report;
453+
454 std::vector<char> whole_message;
455 };
456 }
457
458=== modified file 'src/server/logging/CMakeLists.txt'
459--- src/server/logging/CMakeLists.txt 2013-08-28 03:41:48 +0000
460+++ src/server/logging/CMakeLists.txt 2013-09-26 19:15:16 +0000
461@@ -6,6 +6,7 @@
462 message_processor_report.cpp
463 display_report.cpp
464 input_report.cpp
465+ messenger_report.cpp
466 )
467
468 add_library(
469
470=== added file 'src/server/logging/messenger_report.cpp'
471--- src/server/logging/messenger_report.cpp 1970-01-01 00:00:00 +0000
472+++ src/server/logging/messenger_report.cpp 2013-09-26 19:15:16 +0000
473@@ -0,0 +1,46 @@
474+/*
475+ * Copyright © 2013 Canonical Ltd.
476+ *
477+ * This program is free software: you can redistribute it and/or modify it
478+ * under the terms of the GNU General Public License version 3,
479+ * as published by the Free Software Foundation.
480+ *
481+ * This program is distributed in the hope that it will be useful,
482+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
483+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
484+ * GNU General Public License for more details.
485+ *
486+ * You should have received a copy of the GNU General Public License
487+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
488+ *
489+ * Authored by: Alan Griffiths <alan@octopull.co.uk>
490+ */
491+
492+#include "mir/logging/messenger_report.h"
493+#include "mir/logging/logger.h"
494+
495+#include "std/MirLog.h"
496+#include <std/Log.h>
497+
498+
499+#include <sstream>
500+#include <cstring>
501+#include <mutex>
502+
503+namespace ml = mir::logging;
504+
505+ml::MessengerReport::MessengerReport(const std::shared_ptr<Logger>& logger)
506+ : logger(logger)
507+{
508+}
509+
510+const char* ml::MessengerReport::component()
511+{
512+ static const char* s = "messenger";
513+ return s;
514+}
515+
516+void ml::MessengerReport::error(std::string const& error_message)
517+{
518+ logger->log<Logger::informational>(error_message, component());
519+}
520
521=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
522--- tests/unit-tests/frontend/CMakeLists.txt 2013-09-24 14:13:15 +0000
523+++ tests/unit-tests/frontend/CMakeLists.txt 2013-09-26 19:15:16 +0000
524@@ -8,6 +8,7 @@
525 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp
526 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp
527 ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_session.cpp
528+ ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_messenger.cpp
529 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_sender.cpp
530 ${CMAKE_CURRENT_SOURCE_DIR}/test_global_event_sender.cpp
531 )
532
533=== added file 'tests/unit-tests/frontend/test_socket_messenger.cpp'
534--- tests/unit-tests/frontend/test_socket_messenger.cpp 1970-01-01 00:00:00 +0000
535+++ tests/unit-tests/frontend/test_socket_messenger.cpp 2013-09-26 19:15:16 +0000
536@@ -0,0 +1,37 @@
537+/*
538+ * Copyright © 2013 Canonical Ltd.
539+ *
540+ * This program is free software: you can redistribute it and/or modify
541+ * it under the terms of the GNU General Public License version 3 as
542+ * published by the Free Software Foundation.
543+ *
544+ * This program is distributed in the hope that it will be useful,
545+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
546+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
547+ * GNU General Public License for more details.
548+ *
549+ * You should have received a copy of the GNU General Public License
550+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
551+ *
552+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
553+ */
554+
555+#include "mir/frontend/messenger_report.h"
556+#include "src/server/frontend/socket_messenger.h"
557+
558+#include <gmock/gmock.h>
559+#include <gtest/gtest.h>
560+
561+namespace mf = mir::frontend;
562+
563+using namespace mf::detail;
564+using namespace boost::asio;
565+
566+TEST(SocketMessengerTest, write_failures_never_throw)
567+{
568+ io_service svc;
569+ auto sock = std::make_shared<local::stream_protocol::socket>(svc);
570+ SocketMessenger mess(sock, std::make_shared<mf::NullMessengerReport>());
571+
572+ EXPECT_NO_THROW( mess.send("foo") );
573+}

Subscribers

People subscribed via source and target branches