[Beignet] [PATCH 1/3] Add error handle for command queue destroy.
junyan.he at inbox.com
junyan.he at inbox.com
Thu Aug 4 10:03:11 UTC 2016
From: Junyan He <junyan.he at intel.com>
If some event still in queue when destroy, clear
all of them.
Signed-off-by: Junyan He <junyan.he at intel.com>
---
src/cl_command_queue_enqueue.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/cl_command_queue_enqueue.c b/src/cl_command_queue_enqueue.c
index 7bc6dd3..32545b3 100644
--- a/src/cl_command_queue_enqueue.c
+++ b/src/cl_command_queue_enqueue.c
@@ -22,7 +22,8 @@
#include "cl_alloc.h"
#include <stdio.h>
-static void *worker_thread_function(void *Arg)
+static void *
+worker_thread_function(void *Arg)
{
cl_command_queue_enqueue_worker worker = (cl_command_queue_enqueue_worker)Arg;
cl_command_queue queue = worker->queue;
@@ -166,6 +167,9 @@ LOCAL void
cl_command_queue_destroy_enqueue(cl_command_queue queue)
{
cl_command_queue_enqueue_worker worker = &queue->worker;
+ list_head *pos;
+ list_head *n;
+ cl_event e;
assert(worker->queue == queue);
assert(worker->quit == CL_FALSE);
@@ -179,10 +183,17 @@ cl_command_queue_destroy_enqueue(cl_command_queue queue)
/* We will wait for finish before destroy the command queue. */
if (!list_empty(&worker->enqueued_events)) {
- DEBUGP(DL_WARNING, "There are still some enqueued works in the queue %p when this queue is destroyed,"
- " this may cause very serious problems.\n",
+ DEBUGP(DL_WARNING, "There are still some enqueued works in the queue %p when this"
+ " queue is destroyed, this may cause very serious problems.\n",
queue);
- assert(0);
+
+ list_for_each_safe(pos, n, &worker->enqueued_events)
+ {
+ e = list_entry(pos, _cl_event, enqueue_node);
+ list_del(&e->enqueue_node);
+ cl_event_set_status(e, -1); // Give waiters a chance to wakeup.
+ cl_event_delete(e);
+ }
}
}
--
2.7.4
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
Check it out at http://mysecurelogon.com/password-manager
More information about the Beignet
mailing list