Mesa (9.0): wayland: Don't cancel a roundtrip when any event is received

Kristian Høgsberg krh at kemper.freedesktop.org
Mon Jan 14 21:36:28 UTC 2013


Module: Mesa
Branch: 9.0
Commit: f2da7e720f60e8df96bf2530f35e3e79897e0cb7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2da7e720f60e8df96bf2530f35e3e79897e0cb7

Author: Jonas Ådahl <jadahl at gmail.com>
Date:   Tue Dec 25 13:01:08 2012 +0100

wayland: Don't cancel a roundtrip when any event is received

Since wl_display_dispatch_queue() returns the number of processed events
or -1 on error, only cancel the roundtrip if an -1 is returned.

This also fixes a potential memory corruption bug happening when the
roundtrip does an early return and the callback later writes to the then
out of scope stack allocated `done' parameter.

Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

---

 src/egl/drivers/dri2/platform_wayland.c            |    3 +++
 .../state_trackers/egl/wayland/native_wayland.c    |    5 ++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 9b77b7a..59371d6 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -70,6 +70,9 @@ roundtrip(struct dri2_egl_display *dri2_dpy)
    while (ret != -1 && !done)
       ret = wl_display_dispatch_queue(dri2_dpy->wl_dpy, dri2_dpy->wl_queue);
 
+   if (!done)
+      wl_callback_destroy(callback);
+
    return ret;
 }
 
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index 560e40d..941a094 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -57,9 +57,12 @@ wayland_roundtrip(struct wayland_display *display)
    callback = wl_display_sync(display->dpy);
    wl_callback_add_listener(callback, &sync_listener, &done);
    wl_proxy_set_queue((struct wl_proxy *) callback, display->queue);
-   while (ret == 0 && !done)
+   while (ret != -1 && !done)
       ret = wl_display_dispatch_queue(display->dpy, display->queue);
 
+   if (!done)
+      wl_callback_destroy(callback);
+
    return ret;
 }
 




More information about the mesa-commit mailing list