Merge lp://qastaging/~afrantzis/mir/fix-1317801 into lp://qastaging/mir
Status: | Rejected |
---|---|
Rejected by: | Alexandros Frantzis |
Proposed branch: | lp://qastaging/~afrantzis/mir/fix-1317801 |
Merge into: | lp://qastaging/mir |
Diff against target: |
162 lines (+76/-7) 2 files modified
src/server/compositor/buffer_queue.cpp (+17/-0) tests/unit-tests/compositor/test_buffer_queue.cpp (+59/-7) |
To merge this branch: | bzr merge lp://qastaging/~afrantzis/mir/fix-1317801 |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alberto Aguirre (community) | Needs Fixing | ||
Daniel van Vugt | Needs Fixing | ||
Alan Griffiths | Abstain | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+218996@code.qastaging.launchpad.net |
Commit message
compositor: Fix race in BufferQueue (LP: #1317801)
Reserve the maximum size for the 'buffers' std::vector so that all references to
existing elements of 'buffers' remain valid when we add new elements to it
(i.e. in client_acquire()).
Also add BufferQueueTest
to guard against a seemingly correct, but ultimately wrong, alternative approach to
resolving this race, namely copying the value from the vector instead of using
a reference to it.
Description of the change
compositor: Fix race in BufferQueue
Reserve the maximum size for the 'buffers' std::vector so that all references to
existing elements of 'buffers' remain valid when we add new elements to it
(i.e. in client_acquire()).
Also add BufferQueueTest
Unmerged revisions
- 1618. By Alexandros Frantzis
-
tests: Simplify test
- 1617. By Alexandros Frantzis
-
tests: Use AutoJoinThread to ensure proper cleanup
- 1616. By Alexandros Frantzis
-
compositor: Fix race in BufferQueue
~~~ acquire_ async(q) ; acquire_ requested. wake_up_ everyone( ); acquire_ requested. wait_for_ at_most_ seconds( 3);
108 + std::thread t{
109 + [&]
110 + {
111 + auto handle = client_
112 + client_
113 + handle->wait();
114 + }};
115 +
116 + client_
121 + t.join();
~~~
Can be replaced with:
auto handle = client_ acquire_ async(q) ; >wait_for( std::chrono: :seconds( 3)); THAT(handle- >has_acquired_ buffer( ), Eq(true));
handle-
ASSERT_
~~~ acquire( ) */ thread: :sleep_ for(std: :chrono: :milliseconds{ 10}); release( client_ acquire_ sync(q) ); release( client_ acquire_ sync(q) );
153 + std::thread t{
154 + [&]
155 + {
156 + /* Use in conjuction with a 20ms delay in compositor_
157 + std::this_
158 +
159 + q.client_
160 + q.client_
161 + }};
~~~
Use AutoJoinThread so that thread is still joined in case compositor_acquire or compositor_release throws.