mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-16 21:58:21 +02:00
clover: Add a mutex to guard queue::queued_events
This fixes a potential crash where on a sequence like this:
Thread 0: Check if queue is not empty.
Thread 1: Remove item from queue, making it empty.
Thread 0: Do something assuming queue is not empty.
CC: 10.5 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
(cherry picked from commit f546902d95)
This commit is contained in:
parent
0024b85cc6
commit
5bb7ee4fd6
2 changed files with 4 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ command_queue::flush() {
|
|||
pipe_screen *screen = device().pipe;
|
||||
pipe_fence_handle *fence = NULL;
|
||||
|
||||
std::lock_guard<std::mutex> lock(queued_events_mutex);
|
||||
if (!queued_events.empty()) {
|
||||
pipe->flush(pipe, &fence, 0);
|
||||
|
||||
|
|
@ -69,6 +70,7 @@ command_queue::profiling_enabled() const {
|
|||
|
||||
void
|
||||
command_queue::sequence(hard_event &ev) {
|
||||
std::lock_guard<std::mutex> lock(queued_events_mutex);
|
||||
if (!queued_events.empty())
|
||||
queued_events.back()().chain(ev);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#define CLOVER_CORE_QUEUE_HPP
|
||||
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
|
||||
#include "core/object.hpp"
|
||||
#include "core/context.hpp"
|
||||
|
|
@ -69,6 +70,7 @@ namespace clover {
|
|||
|
||||
cl_command_queue_properties props;
|
||||
pipe_context *pipe;
|
||||
std::mutex queued_events_mutex;
|
||||
std::deque<intrusive_ref<hard_event>> queued_events;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue