Mir

Merge lp:~robertcarr/mir/socket-messenger-race into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Superseded
Proposed branch: lp:~robertcarr/mir/socket-messenger-race
Merge into: lp:~mir-team/mir/trunk
Diff against target: 25 lines (+4/-0)
2 files modified
src/server/frontend/socket_messenger.cpp (+2/-0)
src/server/frontend/socket_messenger.h (+2/-0)
To merge this branch: bzr merge lp:~robertcarr/mir/socket-messenger-race
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+187042@code.launchpad.net

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

Commit message

socket_messenger: Protect whole_message with a lock.

Description of the change

It seems to me that socket messenger may be used from any thread (as a result of the shell generating various events, i.e. focus/unfocus).

This means that we need to protect whole_message with a lock.

To post a comment you must log in.
Revision history for this message
kevin gunn (kgunn72) wrote :

should be ok from mirserver api, no break

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

should retarget to development branch...

other than that though, the fix makes sense

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

I'm not sure this is adequate.

Unless I miss something, the lock needs to be held across the related send() and send_fds() calls originating in ProtobufMessageProcessor::send_response() - not just the send() call.

And that is best approached by changing interfaces so that the body and fds are passed to a single call.

review: Needs Fixing

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-08-28 03:41:48 +0000
3+++ src/server/frontend/socket_messenger.cpp 2013-09-23 15:06:12 +0000
4@@ -49,6 +49,8 @@
5 static_cast<unsigned char>((size >> 8) & 0xff),
6 static_cast<unsigned char>((size >> 0) & 0xff)
7 };
8+
9+ std::unique_lock<std::mutex> lg(message_lock);
10
11 whole_message.resize(sizeof header_bytes + size);
12 std::copy(header_bytes, header_bytes + sizeof header_bytes, whole_message.begin());
13
14=== modified file 'src/server/frontend/socket_messenger.h'
15--- src/server/frontend/socket_messenger.h 2013-08-28 03:41:48 +0000
16+++ src/server/frontend/socket_messenger.h 2013-09-23 15:06:12 +0000
17@@ -42,6 +42,8 @@
18
19 private:
20 std::shared_ptr<boost::asio::local::stream_protocol::socket> socket;
21+
22+ std::mutex message_lock;
23 std::vector<char> whole_message;
24 };
25 }

Subscribers

People subscribed via source and target branches