devilhorns pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=c4e9d294413004bb8253513f77690dfccb8a6d43
commit c4e9d294413004bb8253513f77690dfccb8a6d43 Author: Chris Michael <cp.mich...@samsung.com> Date: Wed Apr 29 11:49:49 2015 -0400 evas-wayland-shm: Minimize race condition when finding free leaf Summary: This fixes a possible race condition that could happen when using more than 2 buffers. Instead of searching for a free buffer in various places, find a free buffer when evas requests the buffer data and save that free buffer as the 'current buffer' @fix Signed-off-by: Chris Michael <cp.mich...@samsung.com> --- src/modules/evas/engines/wayland_shm/evas_shm.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c index 0a05f03..3cea7d2 100644 --- a/src/modules/evas/engines/wayland_shm/evas_shm.c +++ b/src/modules/evas/engines/wayland_shm/evas_shm.c @@ -412,23 +412,16 @@ _evas_shm_surface_swap(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int LOGFN(__FILE__, __LINE__, __FUNCTION__); - for (; i < surface->num_buff; i++) - { - if (surface->leaf[i].busy) continue; - if ((!leaf) || (leaf->valid)) - { - leaf = &surface->leaf[i]; - break; - } - } + leaf = &surface->leaf[surface->curr_buff]; + if (!leaf) return; - if (!leaf) + if (leaf->busy) { - /* WRN("All buffers held by server"); */ + WRN("Trying to use a busy buffer"); return; } - /* DBG("Current Leaf %d", (int)(leaf - &surface->leaf[0])); */ + DBG("Current Leaf %d", (int)(leaf - &surface->leaf[0])); wl_surface_attach(surface->surface, leaf->data->buffer, 0, 0); @@ -450,8 +443,6 @@ _evas_shm_surface_swap(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int surface->dx = 0; surface->dy = 0; surface->redraw = EINA_TRUE; - surface->last_buff = surface->curr_buff; - surface->curr_buff = (int)(leaf - &surface->leaf[0]); } void * @@ -477,7 +468,7 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h) if (!leaf) { - /* WRN("All buffers held by server"); */ + WRN("All buffers held by server"); return NULL; } @@ -486,6 +477,9 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h) if (w) *w = leaf->w; if (h) *h = leaf->h; + surface->last_buff = surface->curr_buff; + surface->curr_buff = (int)(leaf - &surface->leaf[0]); + return leaf->data->map; } --