summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-04-29 11:49:49 -0400
committerChris Michael <cp.michael@samsung.com>2015-04-29 11:49:49 -0400
commitc4e9d294413004bb8253513f77690dfccb8a6d43 (patch)
tree4f9c678dd66fe563a1ad61a55c26e1f31e485b46 /src/modules
parenta3969b4d3ad2708b22248b7715dd5eb15fa78eac (diff)
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.michael@samsung.com>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_shm.c24
1 files 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
412 412
413 LOGFN(__FILE__, __LINE__, __FUNCTION__); 413 LOGFN(__FILE__, __LINE__, __FUNCTION__);
414 414
415 for (; i < surface->num_buff; i++) 415 leaf = &surface->leaf[surface->curr_buff];
416 { 416 if (!leaf) return;
417 if (surface->leaf[i].busy) continue;
418 if ((!leaf) || (leaf->valid))
419 {
420 leaf = &surface->leaf[i];
421 break;
422 }
423 }
424 417
425 if (!leaf) 418 if (leaf->busy)
426 { 419 {
427 /* WRN("All buffers held by server"); */ 420 WRN("Trying to use a busy buffer");
428 return; 421 return;
429 } 422 }
430 423
431 /* DBG("Current Leaf %d", (int)(leaf - &surface->leaf[0])); */ 424 DBG("Current Leaf %d", (int)(leaf - &surface->leaf[0]));
432 425
433 wl_surface_attach(surface->surface, leaf->data->buffer, 0, 0); 426 wl_surface_attach(surface->surface, leaf->data->buffer, 0, 0);
434 427
@@ -450,8 +443,6 @@ _evas_shm_surface_swap(Shm_Surface *surface, Eina_Rectangle *rects, unsigned int
450 surface->dx = 0; 443 surface->dx = 0;
451 surface->dy = 0; 444 surface->dy = 0;
452 surface->redraw = EINA_TRUE; 445 surface->redraw = EINA_TRUE;
453 surface->last_buff = surface->curr_buff;
454 surface->curr_buff = (int)(leaf - &surface->leaf[0]);
455} 446}
456 447
457void * 448void *
@@ -477,7 +468,7 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h)
477 468
478 if (!leaf) 469 if (!leaf)
479 { 470 {
480 /* WRN("All buffers held by server"); */ 471 WRN("All buffers held by server");
481 return NULL; 472 return NULL;
482 } 473 }
483 474
@@ -486,6 +477,9 @@ _evas_shm_surface_data_get(Shm_Surface *surface, int *w, int *h)
486 if (w) *w = leaf->w; 477 if (w) *w = leaf->w;
487 if (h) *h = leaf->h; 478 if (h) *h = leaf->h;
488 479
480 surface->last_buff = surface->curr_buff;
481 surface->curr_buff = (int)(leaf - &surface->leaf[0]);
482
489 return leaf->data->map; 483 return leaf->data->map;
490} 484}
491 485