Mir

Merge lp:~alan-griffiths/mir/fix-intermittent-memory-leak into lp:mir

Proposed by Alan Griffiths on 2015-07-28
Status: Merged
Approved by: Alan Griffiths on 2015-07-29
Approved revision: 2792
Merged at revision: 2792
Proposed branch: lp:~alan-griffiths/mir/fix-intermittent-memory-leak
Merge into: lp:mir
Diff against target: 33 lines (+4/-1)
2 files modified
src/client/mir_connection.cpp (+2/-1)
src/client/mir_connection.h (+2/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-intermittent-memory-leak
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve on 2015-07-29
Daniel van Vugt 2015-07-28 Approve on 2015-07-29
PS Jenkins bot continuous-integration Approve on 2015-07-28
Review via email: mp+266127@code.launchpad.net

Commit Message

client: fix intermittent leak of pong callback

Description of the Change

client: fix intermittent leak of pong callback

While investigating FD leans in the acceptance test I occasionally saw the pong callback being leaked. (Presumably because the call to Done() races with shutdown.)

To post a comment you must log in.
Daniel van Vugt (vanvugt) :
review: Approve
Alexandros Frantzis (afrantzis) wrote :

OK.

review: Approve
Alan Griffiths (alan-griffiths) wrote :

Needs tweaking

2792. By Alan Griffiths on 2015-07-29

Ensure pong_callback lives until after eventloop destruction (which can touch it)

Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/mir_connection.cpp'
2--- src/client/mir_connection.cpp 2015-07-25 08:10:48 +0000
3+++ src/client/mir_connection.cpp 2015-07-29 09:05:52 +0000
4@@ -122,6 +122,7 @@
5 ping_handler{conf.the_ping_handler()},
6 surface_map(conf.the_surface_map()),
7 event_handler_register(conf.the_event_handler_register()),
8+ pong_callback(google::protobuf::NewPermanentCallback(&google::protobuf::DoNothing)),
9 eventloop{new md::ThreadedDispatcher{"RPC Thread", std::dynamic_pointer_cast<md::Dispatchable>(channel)}}
10 {
11 connect_result->set_error("connect not called");
12@@ -552,7 +553,7 @@
13 {
14 auto pong = mcl::make_protobuf_object<mir::protobuf::PingEvent>();
15 pong->set_serial(serial);
16- server.pong(0, pong.get(), void_response.get(), google::protobuf::NewCallback(&google::protobuf::DoNothing));
17+ server.pong(0, pong.get(), void_response.get(), pong_callback.get());
18 }
19
20 void MirConnection::register_display_change_callback(mir_display_config_callback callback, void* context)
21
22=== modified file 'src/client/mir_connection.h'
23--- src/client/mir_connection.h 2015-07-25 08:10:48 +0000
24+++ src/client/mir_connection.h 2015-07-29 09:05:52 +0000
25@@ -215,6 +215,8 @@
26
27 std::shared_ptr<mir::client::EventHandlerRegister> const event_handler_register;
28
29+ std::unique_ptr<google::protobuf::Closure> const pong_callback;
30+
31 std::unique_ptr<mir::dispatch::ThreadedDispatcher> const eventloop;
32
33 std::shared_ptr<mir::client::ClientBufferStreamFactory> buffer_stream_factory;

Subscribers

People subscribed via source and target branches