Mir

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

Proposed by Daniel van Vugt
Status: Merged
Approved by: Chris Halse Rogers
Approved revision: no longer in the source branch.
Merged at revision: 1754
Proposed branch: lp:~vanvugt/mir/fix-1338902
Merge into: lp:mir
Diff against target: 39 lines (+9/-1)
1 file modified
tests/unit-tests/client/test_event_distributor.cpp (+9/-1)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1338902
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve
PS Jenkins bot (community) continuous-integration Approve
Nick Dedekind Pending
Review via email: mp+225929@code.launchpad.net

Commit message

Fix crashing test: EventDistributorTest.succeeds_with_thread_delete_unregister
due to multiple mutex unlocks (LP: #1338902)

Also added a yield() to stop the test from taking forever under valgrind.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

This still seems to contain a race.

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

The failure doesn't seem related to the branch. Try again...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/unit-tests/client/test_event_distributor.cpp'
2--- tests/unit-tests/client/test_event_distributor.cpp 2014-06-11 16:11:32 +0000
3+++ tests/unit-tests/client/test_event_distributor.cpp 2014-07-09 06:07:45 +0000
4@@ -107,12 +107,18 @@
5 EventCatcher(mcl::EventDistributor* event_distributor)
6 : event_distributor(event_distributor)
7 {
8+ locked = false;
9 reg = event_distributor->register_event_handler(
10 [this](MirEvent const&)
11 {
12- mutex.unlock();
13+ if (locked)
14+ {
15+ locked = false;
16+ mutex.unlock();
17+ }
18 });
19 mutex.lock();
20+ locked = true;
21 }
22 ~EventCatcher()
23 {
24@@ -122,6 +128,7 @@
25
26 mcl::EventDistributor* event_distributor;
27 int reg;
28+ bool locked;
29 std::mutex mutex;
30 };
31
32@@ -145,6 +152,7 @@
33
34 while(!thread_done.woken()) {
35 event_distributor.handle_event(e);
36+ std::this_thread::yield();
37 }
38
39 thread.join();

Subscribers

People subscribed via source and target branches