emotion: fix a race condition on shutdown when still saving a file.
authorcedric <cedric>
Tue, 28 Aug 2012 09:27:54 +0000 (09:27 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Aug 2012 09:27:54 +0000 (09:27 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/emotion@75770 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/lib/emotion_smart.c

index 2aaa70c..c85115a 100644 (file)
--- a/ChangeLog
+++ b/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/NEWS b/NEWS
index 07d2b98..cedcaf4 100644 (file)
--- a/NEWS
+++ b/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:
 
index 873b587..48eafda 100644 (file)
@@ -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);