From 5e2e5f85345b29948876440e735c55d97c1e53d5 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 7 Dec 2015 17:13:09 +0900 Subject: [PATCH] elimiate race condition of pp callback Change-Id: Ie0599e2d7670ce2c31d2c8537c243a8e9d6f1fa7 Signed-off-by: Junkyeong Kim --- src/tdm_pp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tdm_pp.c b/src/tdm_pp.c index 91642af..959674d 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -54,8 +54,21 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static void _tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, void *user_data) { + tdm_private_pp *private_pp = user_data; + tdm_private_display *private_display = private_pp->private_display; + int lock_after_cb_done = 0; + + if (pthread_mutex_trylock(&private_display->lock)) + { + pthread_mutex_unlock(&private_display->lock); + lock_after_cb_done = 1; + } + tdm_buffer_unref_backend(tdm_buffer_get(src)); tdm_buffer_unref_backend(tdm_buffer_get(dst)); + + if (lock_after_cb_done) + pthread_mutex_lock(&private_display->lock); } INTERN tdm_private_pp* -- 2.7.4