Mir

Merge lp:~vanvugt/mir/fix-1226139 into lp:mir

Proposed by Robert Ancell
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/fix-1226139
Merge into: lp:mir
Diff against target: 72 lines (+44/-2)
3 files modified
src/server/frontend/socket_messenger.cpp (+9/-2)
tests/unit-tests/frontend/CMakeLists.txt (+1/-0)
tests/unit-tests/frontend/test_socket_messenger.cpp (+34/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1226139
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Robert Ancell Approve
Robert Carr Pending
Review via email: mp+187649@code.launchpad.net

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

Commit message

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)

Description of the change

I'm not convinced this is the right answer long term. Long term we should be ensuring that all messages are sent before the socket is closed. But that kind of race will take much longer to solve. And right now we need a quick fix to stop the server crashing on client disconnect. Particularly if this is one of the crashes holding up touch...

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote : Posted in a previous version of this proposal

+1 on the long term needs a better solution. It would be nice if at least we logged something to stderr so we know if this occurs though since a future bug might be hidden by this change. Otherwise looks good.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

I'm not entirely convinced by the assertion that the existing code will only throw after we've closed the socket. It would probably better to allow the exception to propagate to a point that can clear down the client session (including the connection).

OTOH not handling the exception is a very bad thing and this is an improvement.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote : Posted in a previous version of this proposal

I've lost quite a bit of time in the past to an 'exception blackhole' in frontend, so I'm a little worried about that, or just that we will lose track of it.

Let's report the exception at least, proposed a merge in to this branch:
https://code.launchpad.net/~robertcarr/mir/socket-messenger-reporting/+merge/187023

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

According to today's process this should be resubmitted targeting ~mir-team/mir/development-branch.

(It isn't an ABI break, but routing through development-branch avoids missteps.)

review: Needs Resubmitting
Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1072
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~vanvugt/mir/fix-1226139/+merge/187649/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mir-team-mir-development-branch-ci/30/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-android-saucy-i386-build/2141/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-clang-saucy-amd64-build/2026/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-team-mir-development-branch-saucy-amd64-ci/30/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/mir-team-mir-development-branch-ci/30/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

8 +<<<<<<< TREE
9 boost::system::error_code err;
10 ba::write(*socket, ba::buffer(whole_message), err);
11 +=======
12 + try
13 + {
14 + ba::write(*socket, ba::buffer(whole_message));
15 + }
16 + catch (std::exception &)
17 + {
18 + // Don't care
19 + }
20 +>>>>>>> MERGE-SOURCE

I prefer "tree"

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

8 +<<<<<<< TREE
9 boost::system::error_code err;
10 ba::write(*socket, ba::buffer(whole_message), err);
11 +=======
12 + try
13 + {
14 + ba::write(*socket, ba::buffer(whole_message));
15 + }
16 + catch (std::exception &)
17 + {
18 + // Don't care
19 + }
20 +>>>>>>> MERGE-SOURCE

I prefer "tree"

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

I got branch confusion at: https://code.launchpad.net/~robertcarr/mir/socket-messenger-reporting/+merge/187822 so lets merge socket-messenger-reporting directly instead?

lp:~vanvugt/mir/fix-1226139 updated
1073. By Daniel van Vugt

Merge latest dev branch and resolve a conflict.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

8 - boost::system::error_code err;
9 - ba::write(*socket, ba::buffer(whole_message), err);
10 + try
11 + {
12 + boost::system::error_code err;
13 + ba::write(*socket, ba::buffer(whole_message), err);
14 + }
15 + catch (std::exception &)
16 + {
17 + // Don't care
18 + }

The try...catch block is redundant (this version of write doesn't throw - it populates err).

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Umm, so the bug is entirely fixed already?

That means we should reject the proposal.

Unmerged revisions

1073. By Daniel van Vugt

Merge latest dev branch and resolve a conflict.

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 'src/server/frontend/socket_messenger.cpp'
2--- src/server/frontend/socket_messenger.cpp 2013-09-25 14:18:18 +0000
3+++ src/server/frontend/socket_messenger.cpp 2013-09-27 08:21:55 +0000
4@@ -59,8 +59,15 @@
5 // function has completed (if it would be executed asynchronously.
6 // NOTE: we rely on this synchronous behavior as per the comment in
7 // mf::SessionMediator::create_surface
8- boost::system::error_code err;
9- ba::write(*socket, ba::buffer(whole_message), err);
10+ try
11+ {
12+ boost::system::error_code err;
13+ ba::write(*socket, ba::buffer(whole_message), err);
14+ }
15+ catch (std::exception &)
16+ {
17+ // Don't care
18+ }
19 }
20
21 void mfd::SocketMessenger::send_fds(std::vector<int32_t> const& fds)
22
23=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
24--- tests/unit-tests/frontend/CMakeLists.txt 2013-09-24 14:13:15 +0000
25+++ tests/unit-tests/frontend/CMakeLists.txt 2013-09-27 08:21:55 +0000
26@@ -8,6 +8,7 @@
27 ${CMAKE_CURRENT_SOURCE_DIR}/test_resource_cache.cpp
28 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator.cpp
29 ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_session.cpp
30+ ${CMAKE_CURRENT_SOURCE_DIR}/test_socket_messenger.cpp
31 ${CMAKE_CURRENT_SOURCE_DIR}/test_event_sender.cpp
32 ${CMAKE_CURRENT_SOURCE_DIR}/test_global_event_sender.cpp
33 )
34
35=== added file 'tests/unit-tests/frontend/test_socket_messenger.cpp'
36--- tests/unit-tests/frontend/test_socket_messenger.cpp 1970-01-01 00:00:00 +0000
37+++ tests/unit-tests/frontend/test_socket_messenger.cpp 2013-09-27 08:21:55 +0000
38@@ -0,0 +1,34 @@
39+/*
40+ * Copyright © 2013 Canonical Ltd.
41+ *
42+ * This program is free software: you can redistribute it and/or modify
43+ * it under the terms of the GNU General Public License version 3 as
44+ * published by the Free Software Foundation.
45+ *
46+ * This program is distributed in the hope that it will be useful,
47+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
48+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+ * GNU General Public License for more details.
50+ *
51+ * You should have received a copy of the GNU General Public License
52+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
53+ *
54+ * Authored by: Daniel van Vugt <daniel.van.vugt@canonical.com>
55+ */
56+
57+#include "src/server/frontend/socket_messenger.h"
58+
59+#include <gmock/gmock.h>
60+#include <gtest/gtest.h>
61+
62+using namespace mir::frontend::detail;
63+using namespace boost::asio;
64+
65+TEST(SocketMessengerTest, write_failures_never_throw)
66+{
67+ io_service svc;
68+ auto sock = std::make_shared<local::stream_protocol::socket>(svc);
69+ SocketMessenger mess(sock);
70+
71+ EXPECT_NO_THROW( mess.send("foo") );
72+}

Subscribers

People subscribed via source and target branches