[Mesa-dev] [PATCH v11 09/15] vulkan/wsi/x11: Cleanly handle shutdowns in FIFO thread

Daniel Stone daniels at collabora.com
Wed Feb 21 14:05:53 UTC 2018


The FIFO thread signals shutdown by pushing UINT32_MAX into the acquire
queue, and shutdown is signaled to it by pushing UINT32_MAX into the
present queue.

Explicitly catch a push of UINT32_MAX in either direction and treat this
as error.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 src/vulkan/wsi/wsi_common_x11.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index e84572810d3..dadada82ef1 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -832,7 +832,7 @@ x11_acquire_next_image_from_queue(struct x11_swapchain *chain,
    VkResult result = wsi_queue_pull(&chain->acquire_queue,
                                     &image_index, timeout);
    /* On error, the thread has shut down, so safe to update chain->status */
-   if (result < 0)
+   if (result < 0 || image_index == UINT32_MAX)
       return x11_swapchain_result(chain, result);
 
    assert(image_index < chain->base.image_count);
@@ -938,7 +938,7 @@ x11_manage_fifo_queues(void *state)
       result = wsi_queue_pull(&chain->present_queue, &image_index, INT64_MAX);
       if (result < 0) {
          goto fail;
-      } else if (chain->status < 0) {
+      } else if (chain->status < 0 || image_index == UINT32_MAX) {
          /* The status can change underneath us if the swapchain is destroyed
           * from another thread.
           */
-- 
2.14.3



More information about the mesa-dev mailing list