From 9cb7eac7d268fe91a71bc238df7be391dfb89076 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Tue, 28 Aug 2012 09:27:54 +0000 Subject: [PATCH] emotion: fix a race condition on shutdown when still saving a file. SVN revision: 75770 --- legacy/emotion/ChangeLog | 1 + legacy/emotion/NEWS | 1 + legacy/emotion/src/lib/emotion_smart.c | 31 ++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/legacy/emotion/ChangeLog b/legacy/emotion/ChangeLog index 2aaa70cf90..c85115a5c9 100644 --- a/legacy/emotion/ChangeLog +++ b/legacy/emotion/ChangeLog @@ -45,3 +45,4 @@ 2012-08-28 Cedric Bail * Reset VLC pipeline on EOS. + * Fix a race condition on shutdown when still saving a file position. diff --git a/legacy/emotion/NEWS b/legacy/emotion/NEWS index 07d2b98378..cedcaf4662 100644 --- a/legacy/emotion/NEWS +++ b/legacy/emotion/NEWS @@ -16,6 +16,7 @@ Fixes: - fix race condition in gstreamer render function on shutdown and file set. - fix priority set/get for gstreamer. - reset VLC pipeline on EOS. + - fix race condition on shutdown when still saving a file position. Improvements: diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c index 873b587c21..48eafdacc7 100644 --- a/legacy/emotion/src/lib/emotion_smart.c +++ b/legacy/emotion/src/lib/emotion_smart.c @@ -71,6 +71,7 @@ struct _Smart_Data #ifdef HAVE_EIO Eio_File *load_xattr; + Eio_File *save_xattr; #endif struct { @@ -481,6 +482,8 @@ emotion_object_file_set(Evas_Object *obj, const char *file) /* Only cancel the load_xattr or we will loose ref to time_seek stringshare */ if (sd->load_xattr) eio_file_cancel(sd->load_xattr); sd->load_xattr = NULL; + if (sd->save_xattr) eio_file_cancel(sd->save_xattr); + sd->save_xattr = NULL; #endif return EINA_TRUE; @@ -1416,19 +1419,30 @@ emotion_object_last_position_load(Evas_Object *obj) #ifdef HAVE_EIO static void -_eio_save_xattr_done(void *data, Eio_File *handler __UNUSED__) +_eio_save_xattr_cleanup(Smart_Data *sd, Eio_File *handler) +{ + if (handler == sd->save_xattr) sd->save_xattr = NULL; + + EINA_REFCOUNT_UNREF(sd) + _smart_data_free(sd); +} + +static void +_eio_save_xattr_done(void *data, Eio_File *handler) { Smart_Data *sd = data; evas_object_smart_callback_call(sd->obj, SIG_POSITION_SAVE_SUCCEED, NULL); + _eio_save_xattr_cleanup(sd, handler); } static void -_eio_save_xattr_error(void *data, Eio_File *handler __UNUSED__, int err __UNUSED__) +_eio_save_xattr_error(void *data, Eio_File *handler, int err __UNUSED__) { Smart_Data *sd = data; evas_object_smart_callback_call(sd->obj, SIG_POSITION_SAVE_FAILED, NULL); + _eio_save_xattr_cleanup(sd, handler); } #endif @@ -1449,8 +1463,17 @@ emotion_object_last_position_save(Evas_Object *obj) return ; #ifdef HAVE_EIO - eio_file_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0, - _eio_save_xattr_done, _eio_save_xattr_error, sd); + if (sd->save_xattr) return ; + + EINA_REFCOUNT_REF(sd); + + sd->save_xattr = eio_file_xattr_double_set(tmp, + "user.e.time_seek", + emotion_object_position_get(obj), + 0, + _eio_save_xattr_done, + _eio_save_xattr_error, + sd); #else if (eina_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0)) evas_object_smart_callback_call(obj, SIG_POSITION_SAVE_SUCCEED, NULL);