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
=== modified file 'debian/changelog'
--- debian/changelog 2013-09-26 02:41:07 +0000
+++ debian/changelog 2013-09-26 19:15:16 +0000
@@ -1,4 +1,4 @@
1mir (0.0.12-0ubuntu1) UNRELEASED; urgency=low1mir (0.0.12+13.10.20130926.1-0ubuntu1) saucy; urgency=low
22
3 [ kg ]3 [ kg ]
4 * bump version for ABI break (LP: #1229212)4 * bump version for ABI break (LP: #1229212)
@@ -6,7 +6,13 @@
6 [ Robert Ancell ]6 [ Robert Ancell ]
7 * Bump version to 0.0.127 * Bump version to 0.0.12
88
9 -- Robert Ancell <robert.ancell@canonical.com> Thu, 26 Sep 2013 09:34:23 +12009 [ Alexandros Frantzis ]
10 * tests: Fix compiler warning about maybe-uninitialized struct member
11
12 [ Ubuntu daily release ]
13 * Automatic snapshot from revision 1084
14
15 -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 26 Sep 2013 08:39:29 +0000
1016
11mir (0.0.11+13.10.20130924.1-0ubuntu1) saucy; urgency=low17mir (0.0.11+13.10.20130924.1-0ubuntu1) saucy; urgency=low
1218
1319
=== modified file 'include/server/mir/default_server_configuration.h'
--- include/server/mir/default_server_configuration.h 2013-09-24 11:43:27 +0000
+++ include/server/mir/default_server_configuration.h 2013-09-26 19:15:16 +0000
@@ -46,6 +46,7 @@
46class SessionCreator;46class SessionCreator;
47class SessionMediatorReport;47class SessionMediatorReport;
48class MessageProcessorReport;48class MessageProcessorReport;
49class MessengerReport;
49class SessionAuthorizer;50class SessionAuthorizer;
50class EventSink;51class EventSink;
51class DisplayChanger;52class DisplayChanger;
@@ -165,6 +166,7 @@
165 * @{ */166 * @{ */
166 virtual std::shared_ptr<frontend::SessionMediatorReport> the_session_mediator_report();167 virtual std::shared_ptr<frontend::SessionMediatorReport> the_session_mediator_report();
167 virtual std::shared_ptr<frontend::MessageProcessorReport> the_message_processor_report();168 virtual std::shared_ptr<frontend::MessageProcessorReport> the_message_processor_report();
169 virtual std::shared_ptr<frontend::MessengerReport> the_messenger_report();
168 virtual std::shared_ptr<frontend::SessionAuthorizer> the_session_authorizer();170 virtual std::shared_ptr<frontend::SessionAuthorizer> the_session_authorizer();
169 virtual std::shared_ptr<frontend::Shell> the_frontend_shell();171 virtual std::shared_ptr<frontend::Shell> the_frontend_shell();
170 virtual std::shared_ptr<frontend::EventSink> the_global_event_sink();172 virtual std::shared_ptr<frontend::EventSink> the_global_event_sink();
@@ -270,6 +272,7 @@
270 CachedPtr<frontend::ProtobufIpcFactory> ipc_factory;272 CachedPtr<frontend::ProtobufIpcFactory> ipc_factory;
271 CachedPtr<frontend::SessionMediatorReport> session_mediator_report;273 CachedPtr<frontend::SessionMediatorReport> session_mediator_report;
272 CachedPtr<frontend::MessageProcessorReport> message_processor_report;274 CachedPtr<frontend::MessageProcessorReport> message_processor_report;
275 CachedPtr<frontend::MessengerReport> messenger_report;
273 CachedPtr<frontend::SessionAuthorizer> session_authorizer;276 CachedPtr<frontend::SessionAuthorizer> session_authorizer;
274 CachedPtr<frontend::EventSink> global_event_sink;277 CachedPtr<frontend::EventSink> global_event_sink;
275 CachedPtr<frontend::SessionCreator> session_creator;278 CachedPtr<frontend::SessionCreator> session_creator;
276279
=== modified file 'include/server/mir/frontend/connector_report.h'
--- include/server/mir/frontend/connector_report.h 2013-09-24 16:20:17 +0000
+++ include/server/mir/frontend/connector_report.h 2013-09-26 19:15:16 +0000
@@ -42,7 +42,6 @@
42class NullConnectorReport : public ConnectorReport42class NullConnectorReport : public ConnectorReport
43{43{
44public:44public:
45
46 void error(std::exception const& error);45 void error(std::exception const& error);
47};46};
48}47}
4948
=== added file 'include/server/mir/frontend/messenger_report.h'
--- include/server/mir/frontend/messenger_report.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/frontend/messenger_report.h 2013-09-26 19:15:16 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef MIR_FRONTEND_MESSENGER_REPORT_H_
20#define MIR_FRONTEND_MESSENGER_REPORT_H_
21
22#include <string>
23
24namespace mir
25{
26namespace frontend
27{
28
29class MessengerReport
30{
31public:
32 virtual void error(std::string const& error_message) = 0;
33
34protected:
35 virtual ~MessengerReport() = default;
36 MessengerReport() = default;
37 MessengerReport(const MessengerReport&) = delete;
38 MessengerReport& operator=(const MessengerReport&) = delete;
39};
40
41class NullMessengerReport : public MessengerReport
42{
43public:
44 void error(std::string const& error_message);
45};
46}
47}
48
49#endif // MIR_FRONTEND_MESSENGER_REPORT_H_
050
=== modified file 'include/server/mir/frontend/protobuf_ipc_factory.h'
--- include/server/mir/frontend/protobuf_ipc_factory.h 2013-08-28 03:41:48 +0000
+++ include/server/mir/frontend/protobuf_ipc_factory.h 2013-09-26 19:15:16 +0000
@@ -32,6 +32,7 @@
32class EventSink;32class EventSink;
33class ResourceCache;33class ResourceCache;
34class MessageProcessorReport;34class MessageProcessorReport;
35class MessengerReport;
3536
36class ProtobufIpcFactory37class ProtobufIpcFactory
37{38{
@@ -39,7 +40,8 @@
39 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(40 virtual std::shared_ptr<protobuf::DisplayServer> make_ipc_server(
40 std::shared_ptr<EventSink> const& sink, bool authorized_to_resize_display) = 0;41 std::shared_ptr<EventSink> const& sink, bool authorized_to_resize_display) = 0;
41 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;42 virtual std::shared_ptr<ResourceCache> resource_cache() = 0;
42 virtual std::shared_ptr<MessageProcessorReport> report() = 0;43 virtual std::shared_ptr<MessageProcessorReport> message_processor_report() = 0;
44 virtual std::shared_ptr<MessengerReport> messenger_report() = 0;
4345
44protected:46protected:
45 ProtobufIpcFactory() {}47 ProtobufIpcFactory() {}
4648
=== added file 'include/server/mir/logging/messenger_report.h'
--- include/server/mir/logging/messenger_report.h 1970-01-01 00:00:00 +0000
+++ include/server/mir/logging/messenger_report.h 2013-09-26 19:15:16 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_LOGGING_MESSENGER_REPORT_H_
20#define MIR_LOGGING_MESSENGER_REPORT_H_
21
22#include "mir/frontend/messenger_report.h"
23
24#include <memory>
25
26namespace mir
27{
28namespace logging
29{
30class Logger;
31
32class MessengerReport : public frontend::MessengerReport
33{
34public:
35 MessengerReport(std::shared_ptr<Logger> const& logger);
36 virtual ~MessengerReport() noexcept(true) = default;
37
38 void error(std::string const& error_message);
39
40private:
41 char const* component();
42 std::shared_ptr<Logger> const logger;
43};
44
45}
46}
47
48
49#endif /* MIR_LOGGING_MESSENGER_REPORT_H_ */
050
=== modified file 'include/test/mir_test_doubles/stub_ipc_factory.h'
--- include/test/mir_test_doubles/stub_ipc_factory.h 2013-08-28 03:41:48 +0000
+++ include/test/mir_test_doubles/stub_ipc_factory.h 2013-09-26 19:15:16 +0000
@@ -24,6 +24,7 @@
24#include "mir/frontend/protobuf_ipc_factory.h"24#include "mir/frontend/protobuf_ipc_factory.h"
25#include "mir/frontend/resource_cache.h"25#include "mir/frontend/resource_cache.h"
26#include "mir/frontend/null_message_processor_report.h"26#include "mir/frontend/null_message_processor_report.h"
27#include "mir/frontend/messenger_report.h"
2728
28namespace mir29namespace mir
29{30{
@@ -53,10 +54,14 @@
53 return cache;54 return cache;
54 }55 }
5556
56 virtual std::shared_ptr<frontend::MessageProcessorReport> report()57 virtual std::shared_ptr<frontend::MessageProcessorReport> message_processor_report()
57 {58 {
58 return std::make_shared<frontend::NullMessageProcessorReport>();59 return std::make_shared<frontend::NullMessageProcessorReport>();
59 }60 }
61 virtual std::shared_ptr<frontend::MessengerReport> messenger_report()
62 {
63 return std::make_shared<frontend::NullMessengerReport>();
64 }
6065
61 std::shared_ptr<protobuf::DisplayServer> server;66 std::shared_ptr<protobuf::DisplayServer> server;
62 std::shared_ptr<frontend::ResourceCache> const cache;67 std::shared_ptr<frontend::ResourceCache> const cache;
6368
=== modified file 'src/server/default_server_configuration.cpp'
--- src/server/default_server_configuration.cpp 2013-09-24 17:25:47 +0000
+++ src/server/default_server_configuration.cpp 2013-09-26 19:15:16 +0000
@@ -30,6 +30,7 @@
30#include "mir/frontend/protobuf_ipc_factory.h"30#include "mir/frontend/protobuf_ipc_factory.h"
31#include "mir/frontend/session_mediator_report.h"31#include "mir/frontend/session_mediator_report.h"
32#include "mir/frontend/null_message_processor_report.h"32#include "mir/frontend/null_message_processor_report.h"
33#include "mir/frontend/messenger_report.h"
33#include "mir/frontend/session_mediator.h"34#include "mir/frontend/session_mediator.h"
34#include "mir/frontend/session_authorizer.h"35#include "mir/frontend/session_authorizer.h"
35#include "mir/frontend/global_event_sender.h"36#include "mir/frontend/global_event_sender.h"
@@ -75,6 +76,7 @@
75#include "mir/logging/session_mediator_report.h"76#include "mir/logging/session_mediator_report.h"
76#include "mir/logging/message_processor_report.h"77#include "mir/logging/message_processor_report.h"
77#include "mir/logging/display_report.h"78#include "mir/logging/display_report.h"
79#include "mir/logging/messenger_report.h"
78#include "mir/lttng/message_processor_report.h"80#include "mir/lttng/message_processor_report.h"
79#include "mir/lttng/input_report.h"81#include "mir/lttng/input_report.h"
80#include "mir/shell/surface_source.h"82#include "mir/shell/surface_source.h"
@@ -113,13 +115,15 @@
113 explicit DefaultIpcFactory(115 explicit DefaultIpcFactory(
114 std::shared_ptr<mf::Shell> const& shell,116 std::shared_ptr<mf::Shell> const& shell,
115 std::shared_ptr<mf::SessionMediatorReport> const& sm_report,117 std::shared_ptr<mf::SessionMediatorReport> const& sm_report,
116 std::shared_ptr<mf::MessageProcessorReport> const& mr_report,118 std::shared_ptr<mf::MessageProcessorReport> const& mp_report,
119 std::shared_ptr<mf::MessengerReport> const& messenger_report,
117 std::shared_ptr<mg::Platform> const& graphics_platform,120 std::shared_ptr<mg::Platform> const& graphics_platform,
118 std::shared_ptr<mf::DisplayChanger> const& display_changer,121 std::shared_ptr<mf::DisplayChanger> const& display_changer,
119 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator) :122 std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator) :
120 shell(shell),123 shell(shell),
121 sm_report(sm_report),124 sm_report(sm_report),
122 mp_report(mr_report),125 mp_report(mp_report),
126 msger_report(messenger_report),
123 cache(std::make_shared<mf::ResourceCache>()),127 cache(std::make_shared<mf::ResourceCache>()),
124 graphics_platform(graphics_platform),128 graphics_platform(graphics_platform),
125 display_changer(display_changer),129 display_changer(display_changer),
@@ -131,6 +135,7 @@
131 std::shared_ptr<mf::Shell> shell;135 std::shared_ptr<mf::Shell> shell;
132 std::shared_ptr<mf::SessionMediatorReport> const sm_report;136 std::shared_ptr<mf::SessionMediatorReport> const sm_report;
133 std::shared_ptr<mf::MessageProcessorReport> const mp_report;137 std::shared_ptr<mf::MessageProcessorReport> const mp_report;
138 std::shared_ptr<mf::MessengerReport> const msger_report;
134 std::shared_ptr<mf::ResourceCache> const cache;139 std::shared_ptr<mf::ResourceCache> const cache;
135 std::shared_ptr<mg::Platform> const graphics_platform;140 std::shared_ptr<mg::Platform> const graphics_platform;
136 std::shared_ptr<mf::DisplayChanger> const display_changer;141 std::shared_ptr<mf::DisplayChanger> const display_changer;
@@ -164,16 +169,21 @@
164 return cache;169 return cache;
165 }170 }
166171
167 virtual std::shared_ptr<mf::MessageProcessorReport> report()172 virtual std::shared_ptr<mf::MessageProcessorReport> message_processor_report()
168 {173 {
169 return mp_report;174 return mp_report;
170 }175 }
176 virtual std::shared_ptr<mf::MessengerReport> messenger_report()
177 {
178 return msger_report;
179 }
171};180};
172181
173char const* const server_socket_opt = "file";182char const* const server_socket_opt = "file";
174char const* const no_server_socket_opt = "no-file";183char const* const no_server_socket_opt = "no-file";
175char const* const session_mediator_report_opt = "session-mediator-report";184char const* const session_mediator_report_opt = "session-mediator-report";
176char const* const msg_processor_report_opt = "msg-processor-report";185char const* const msg_processor_report_opt = "msg-processor-report";
186char const* const messenger_report_opt = "messenger-report";
177char const* const display_report_opt = "display-report";187char const* const display_report_opt = "display-report";
178char const* const legacy_input_report_opt = "legacy-input-report";188char const* const legacy_input_report_opt = "legacy-input-report";
179char const* const input_report_opt = "input-report";189char const* const input_report_opt = "input-report";
@@ -824,6 +834,7 @@
824 shell,834 shell,
825 the_session_mediator_report(),835 the_session_mediator_report(),
826 the_message_processor_report(),836 the_message_processor_report(),
837 the_messenger_report(),
827 the_graphics_platform(),838 the_graphics_platform(),
828 the_frontend_display_changer(), allocator);839 the_frontend_display_changer(), allocator);
829 });840 });
@@ -890,6 +901,23 @@
890 });901 });
891}902}
892903
904std::shared_ptr<mf::MessengerReport>
905mir::DefaultServerConfiguration::the_messenger_report()
906{
907 return messenger_report(
908 [this]() -> std::shared_ptr<mf::MessengerReport>
909 {
910 auto report_opt = the_options()->get(messenger_report_opt, off_opt_value);
911 if (report_opt == log_opt_value)
912 {
913 return std::make_shared<ml::MessengerReport>(the_logger());
914 }
915 else
916 {
917 return std::make_shared<mf::NullMessengerReport>();
918 }
919 });
920}
893921
894std::shared_ptr<ml::Logger> mir::DefaultServerConfiguration::the_logger()922std::shared_ptr<ml::Logger> mir::DefaultServerConfiguration::the_logger()
895{923{
896924
=== modified file 'src/server/frontend/CMakeLists.txt'
--- src/server/frontend/CMakeLists.txt 2013-09-24 13:27:33 +0000
+++ src/server/frontend/CMakeLists.txt 2013-09-26 19:15:16 +0000
@@ -5,6 +5,7 @@
5 session_mediator.cpp5 session_mediator.cpp
6 null_session_mediator_report.cpp6 null_session_mediator_report.cpp
7 null_message_processor_report.cpp7 null_message_processor_report.cpp
8 null_messenger_report.cpp
8 protobuf_message_processor.cpp9 protobuf_message_processor.cpp
9 protobuf_buffer_packer.cpp10 protobuf_buffer_packer.cpp
10 null_message_processor.cpp11 null_message_processor.cpp
1112
=== added file 'src/server/frontend/null_messenger_report.cpp'
--- src/server/frontend/null_messenger_report.cpp 1970-01-01 00:00:00 +0000
+++ src/server/frontend/null_messenger_report.cpp 2013-09-26 19:15:16 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "mir/frontend/messenger_report.h"
20
21namespace mf = mir::frontend;
22
23void mf::NullMessengerReport::error(std::string const&)
24{
25}
026
=== modified file 'src/server/frontend/protobuf_session_creator.cpp'
--- src/server/frontend/protobuf_session_creator.cpp 2013-09-24 13:27:33 +0000
+++ src/server/frontend/protobuf_session_creator.cpp 2013-09-26 19:15:16 +0000
@@ -53,7 +53,7 @@
5353
54void mf::ProtobufSessionCreator::create_session_for(std::shared_ptr<ba::local::stream_protocol::socket> const& socket)54void mf::ProtobufSessionCreator::create_session_for(std::shared_ptr<ba::local::stream_protocol::socket> const& socket)
55{55{
56 auto const messenger = std::make_shared<detail::SocketMessenger>(socket);56 auto const messenger = std::make_shared<detail::SocketMessenger>(socket, ipc_factory->messenger_report());
57 auto const client_pid = messenger->client_pid();57 auto const client_pid = messenger->client_pid();
5858
59 if (session_authorizer->connection_is_allowed(client_pid))59 if (session_authorizer->connection_is_allowed(client_pid))
@@ -64,7 +64,7 @@
64 messenger,64 messenger,
65 ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display),65 ipc_factory->make_ipc_server(event_sink, authorized_to_resize_display),
66 ipc_factory->resource_cache(),66 ipc_factory->resource_cache(),
67 ipc_factory->report());67 ipc_factory->message_processor_report());
6868
69 const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor);69 const auto& session = std::make_shared<mfd::SocketSession>(messenger, next_id(), connected_sessions, msg_processor);
70 connected_sessions->add(session);70 connected_sessions->add(session);
7171
=== modified file 'src/server/frontend/socket_messenger.cpp'
--- src/server/frontend/socket_messenger.cpp 2013-09-25 14:18:18 +0000
+++ src/server/frontend/socket_messenger.cpp 2013-09-26 19:15:16 +0000
@@ -18,13 +18,16 @@
1818
19#include "socket_messenger.h"19#include "socket_messenger.h"
20#include "mir/frontend/client_constants.h"20#include "mir/frontend/client_constants.h"
21#include "mir/frontend/messenger_report.h"
2122
22namespace mfd = mir::frontend::detail;23namespace mfd = mir::frontend::detail;
23namespace bs = boost::system;24namespace bs = boost::system;
24namespace ba = boost::asio;25namespace ba = boost::asio;
2526
26mfd::SocketMessenger::SocketMessenger(std::shared_ptr<ba::local::stream_protocol::socket> const& socket)27mfd::SocketMessenger::SocketMessenger(std::shared_ptr<ba::local::stream_protocol::socket> const& socket,
27 : socket(socket)28 std::shared_ptr<MessengerReport> const& report)
29 : socket(socket),
30 report(report)
28{31{
29 whole_message.reserve(serialization_buffer_size);32 whole_message.reserve(serialization_buffer_size);
30}33}
@@ -59,8 +62,14 @@
59 // function has completed (if it would be executed asynchronously.62 // function has completed (if it would be executed asynchronously.
60 // NOTE: we rely on this synchronous behavior as per the comment in63 // NOTE: we rely on this synchronous behavior as per the comment in
61 // mf::SessionMediator::create_surface64 // mf::SessionMediator::create_surface
65
62 boost::system::error_code err;66 boost::system::error_code err;
63 ba::write(*socket, ba::buffer(whole_message), err);67 ba::write(*socket, ba::buffer(whole_message), err);
68 if (!err)
69 {
70 report->error(err.message());
71 }
72
64}73}
6574
66void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds)75void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds)
6776
=== modified file 'src/server/frontend/socket_messenger.h'
--- src/server/frontend/socket_messenger.h 2013-08-28 03:41:48 +0000
+++ src/server/frontend/socket_messenger.h 2013-09-26 19:15:16 +0000
@@ -26,13 +26,16 @@
26{26{
27namespace frontend27namespace frontend
28{28{
29class MessengerReport;
30
29namespace detail31namespace detail
30{32{
31class SocketMessenger : public MessageSender,33class SocketMessenger : public MessageSender,
32 public MessageReceiver34 public MessageReceiver
33{35{
34public:36public:
35 SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket);37 SocketMessenger(std::shared_ptr<boost::asio::local::stream_protocol::socket> const& socket,
38 std::shared_ptr<frontend::MessengerReport> const& report);
3639
37 void send(std::string const& body);40 void send(std::string const& body);
38 void send_fds(std::vector<int32_t> const& fds);41 void send_fds(std::vector<int32_t> const& fds);
@@ -42,6 +45,8 @@
4245
43private:46private:
44 std::shared_ptr<boost::asio::local::stream_protocol::socket> socket;47 std::shared_ptr<boost::asio::local::stream_protocol::socket> socket;
48 std::shared_ptr<MessengerReport> const report;
49
45 std::vector<char> whole_message;50 std::vector<char> whole_message;
46};51};
47}52}
4853
=== modified file 'src/server/logging/CMakeLists.txt'
--- src/server/logging/CMakeLists.txt 2013-08-28 03:41:48 +0000
+++ src/server/logging/CMakeLists.txt 2013-09-26 19:15:16 +0000
@@ -6,6 +6,7 @@
6 message_processor_report.cpp6 message_processor_report.cpp
7 display_report.cpp7 display_report.cpp
8 input_report.cpp8 input_report.cpp
9 messenger_report.cpp
9)10)
1011
11add_library(12add_library(
1213
=== added file 'src/server/logging/messenger_report.cpp'
--- src/server/logging/messenger_report.cpp 1970-01-01 00:00:00 +0000
+++ src/server/logging/messenger_report.cpp 2013-09-26 19:15:16 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "mir/logging/messenger_report.h"
20#include "mir/logging/logger.h"
21
22#include "std/MirLog.h"
23#include <std/Log.h>
24
25
26#include <sstream>
27#include <cstring>
28#include <mutex>
29
30namespace ml = mir::logging;
31
32ml::MessengerReport::MessengerReport(const std::shared_ptr<Logger>& logger)
33 : logger(logger)
34{
35}
36
37const char* ml::MessengerReport::component()
38{
39 static const char* s = "messenger";
40 return s;
41}
42
43void ml::MessengerReport::error(std::string const& error_message)
44{
45 logger->log<Logger::informational>(error_message, component());
46}
047
=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
--- tests/unit-tests/frontend/CMakeLists.txt 2013-09-24 14:13:15 +0000
+++ tests/unit-tests/frontend/CMakeLists.txt 2013-09-26 19:15:16 +0000
@@ -8,6 +8,7 @@
8 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp8 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp
9 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp9 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp
10 ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_session.cpp10 ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_session.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_messenger.cpp
11 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_sender.cpp12 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_sender.cpp
12 ${CMAKE_CURRENT_SOURCE_DIR}/test_global_event_sender.cpp13 ${CMAKE_CURRENT_SOURCE_DIR}/test_global_event_sender.cpp
13)14)
1415
=== added file 'tests/unit-tests/frontend/test_socket_messenger.cpp'
--- tests/unit-tests/frontend/test_socket_messenger.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit-tests/frontend/test_socket_messenger.cpp 2013-09-26 19:15:16 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */
18
19#include "mir/frontend/messenger_report.h"
20#include "src/server/frontend/socket_messenger.h"
21
22#include <gmock/gmock.h>
23#include <gtest/gtest.h>
24
25namespace mf = mir::frontend;
26
27using namespace mf::detail;
28using namespace boost::asio;
29
30TEST(SocketMessengerTest, write_failures_never_throw)
31{
32 io_service svc;
33 auto sock = std::make_shared<local::stream_protocol::socket>(svc);
34 SocketMessenger mess(sock, std::make_shared<mf::NullMessengerReport>());
35
36 EXPECT_NO_THROW( mess.send("foo") );
37}

Subscribers

People subscribed via source and target branches