llvmpipe: clean up rasterization threads upon context destruction
authorBrian Paul <brianp@vmware.com>
Thu, 25 Feb 2010 00:30:43 +0000 (17:30 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 25 Feb 2010 00:30:43 +0000 (17:30 -0700)
Fixes glean hang, bug 26536.

src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast_priv.h

index 07817efd748c25319b3a6728d72bb09f9e9d54c1..82c006d78b0b35331b5e4b28b029198e69185b80 100644 (file)
@@ -826,6 +826,9 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data )
          debug_printf("thread %d waiting for work\n", task->thread_index);
       pipe_semaphore_wait(&task->work_ready);
 
+      if (rast->exit_flag)
+         break;
+
       if (task->thread_index == 0) {
          /* thread[0]:
           *  - get next scene to rasterize
@@ -961,6 +964,20 @@ void lp_rast_destroy( struct lp_rasterizer *rast )
         align_free(rast->tasks[i].tile.color[cbuf]);
    }
 
+   /* Set exit_flag and signal each thread's work_ready semaphore.
+    * Each thread will be woken up, notice that the exit_flag is set and
+    * break out of its main loop.  The thread will then exit.
+    */
+   rast->exit_flag = TRUE;
+   for (i = 0; i < rast->num_threads; i++) {
+      pipe_semaphore_signal(&rast->tasks[i].work_ready);
+   }
+
+   for (i = 0; i < rast->num_threads; i++) {
+      pipe_semaphore_destroy(&rast->tasks[i].work_ready);
+      pipe_semaphore_destroy(&rast->tasks[i].work_done);
+   }
+
    /* for synchronizing rasterization threads */
    pipe_barrier_destroy( &rast->barrier );
 
index 382e169c1c5143c1fd6733bddd9f522925aff538..abc5a9ad8997e2409f331a96ee38377ce4bb6082 100644 (file)
@@ -84,6 +84,7 @@ struct lp_rasterizer
 {
    boolean clipped_tile;
    boolean check_for_clipped_tiles;
+   boolean exit_flag;
 
    /* Framebuffer stuff
     */