Mir

Merge lp:~kdub/mir/fix-1655929 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Alberto Aguirre
Approved revision: no longer in the source branch.
Merged at revision: 3998
Proposed branch: lp:~kdub/mir/fix-1655929
Merge into: lp:mir
Diff against target: 44 lines (+8/-1)
2 files modified
src/client/rpc/mir_protobuf_rpc_channel.cpp (+5/-0)
src/client/rpc/mir_protobuf_rpc_channel.h (+3/-1)
To merge this branch: bzr merge lp:~kdub/mir/fix-1655929
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Alberto Aguirre (community) Approve
Alan Griffiths Approve
Daniel van Vugt Needs Fixing
Review via email: mp+315685@code.launchpad.net

Commit message

start discarding calls in the MirProtobufRpcChannel immediately after getting a disconnect message. This ensures that no calls from other threads can send messages, (or more harmful, put messages in the PendingCallCache that won't get serviced by the server, or forcibly ended by the client shutdown code)

fixes: LP: #1655929

Description of the change

start discarding calls in the MirProtobufRpcChannel immediately after getting a disconnect message. This ensures that no calls from other threads can send messages, (or more harmful, put messages in the PendingCallCache that won't get serviced by the server, or forcibly ended by the client shutdown code)

fixes: LP: #1655929

Will probably want to see a few CI runs without this bug before TA.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3973
https://mir-jenkins.ubuntu.com/job/mir-ci/2874/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3790
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3869
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3859
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3859
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3859
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3817
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3817/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3817
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3817/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3817
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3817/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3817
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3817/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3817
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3817/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3817
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3817/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2874/rebuild

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

+ std::mutex send_mutex;
std::atomic_bool discard{false};

Maybe I'm missing something, but we don't need a mutex to guard an atomic_bool, and I don't see any other use of it.

review: Needs Information
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3973
https://mir-jenkins.ubuntu.com/job/mir-ci/2875/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3791/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3870
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3860
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3860
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3860
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3818
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3818/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3818/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3818/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3818
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3818/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3818
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3818/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3818/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2875/rebuild

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

^^^
Bug 1646375, bug 1616312, bug 1646558

(1) Needs fixing: I agree the mutex should not be required with an atomic.

(2) Needs fixing: We've lost support for safe clean-up in the event that a disconnect is not what destroys the MirConnection object. Probably need to set discard=true inside wait_for_outstanding_calls() now, and rename it appropriately (an idea I toyed with in the past).

I loosely agree with removing discard_future_calls(), as I considered doing the same in the past. Can't remember why I decided in the end not to remove discard_future_calls...

So just some minor needs fixing. But also keep an eye on bug 1653658 to ensure this does not reintroduce it.

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

1) Sure, the remaining atomic wa just missed cleanup.
2) Added the function back. Combining the two have the challenge of coming up with a good name.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3976
https://mir-jenkins.ubuntu.com/job/mir-ci/2883/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3803
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3882
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3872
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3872
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3872
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3830
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3830/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3830
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3830/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3830
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3830/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3830
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3830/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3830
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3830/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3830
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3830/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2883/rebuild

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

OK

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

OK, I think this reduces the window for issues, but you can still have a

A main thread that does
1. async mir_surface_releae
2. mir_connect_release

Depending on timing:

The mir client dispatching thread while handling the surface release ack from the server,
can initiate more RPC calls (because window/surface release their resources) and puts some pending calls in the cache.

The client main thread can then call mir_connect_release, server responds, but pending calls above won't' be satisfied.

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3976
https://mir-jenkins.ubuntu.com/job/mir-ci/2891/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3812
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3891
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3881
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3881
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3881
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3839
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3839/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3839
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3839/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3839
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3839/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3839
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3839/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3839
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3839/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3839
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3839/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2891/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.cpp'
2--- src/client/rpc/mir_protobuf_rpc_channel.cpp 2017-01-24 12:33:31 +0000
3+++ src/client/rpc/mir_protobuf_rpc_channel.cpp 2017-01-27 12:36:33 +0000
4@@ -197,6 +197,7 @@
5 google::protobuf::MessageLite* response,
6 google::protobuf::Closure* complete)
7 {
8+ std::lock_guard<std::mutex> lk(discard_mutex);
9 if (discard)
10 {
11 /*
12@@ -211,6 +212,9 @@
13 return;
14 }
15
16+ if (method_name == "disconnect")
17+ discard = true;
18+
19 // Only send message when details saved for handling response
20 std::vector<mir::Fd> fds;
21 if (parameters->GetTypeName() == "mir.protobuf.BufferRequest")
22@@ -244,6 +248,7 @@
23
24 void mclr::MirProtobufRpcChannel::discard_future_calls()
25 {
26+ std::unique_lock<decltype(discard_mutex)> lk(discard_mutex);
27 discard = true;
28 }
29
30
31=== modified file 'src/client/rpc/mir_protobuf_rpc_channel.h'
32--- src/client/rpc/mir_protobuf_rpc_channel.h 2017-01-18 02:29:37 +0000
33+++ src/client/rpc/mir_protobuf_rpc_channel.h 2017-01-27 12:36:33 +0000
34@@ -104,7 +104,9 @@
35 private:
36 std::shared_ptr<RpcReport> const rpc_report;
37 detail::PendingCallCache pending_calls;
38- std::atomic_bool discard{false};
39+
40+ std::mutex discard_mutex;
41+ bool discard{false};
42
43 static constexpr size_t size_of_header = 2;
44 detail::SendBuffer header_bytes;

Subscribers

People subscribed via source and target branches