Fix a bug with using Eio_File handler in main callback.
authorGuillaume Friloux <guillaume@friloux.me>
Thu, 9 Oct 2014 19:41:55 +0000 (21:41 +0200)
committerzmike <michael.blumenkrantz@gmail.com>
Thu, 9 Oct 2014 19:53:01 +0000 (15:53 -0400)
When using eio_file_stat_ls() (or any other exposing Eio_File *handler),
it will not be possible to use it from the main callback due to eio
freeing data too fast from the thread.

Moved frees from _eio_file_eina_ls_heavy() to eio_async_end() to be
sure that all the calls to main callback are over.
This implied adding the Eina_Iterator from eina_file_stat_ls to
the _Eio_File_Ls structure.

src/lib/eio/eio_file.c
src/lib/eio/eio_private.h

index 0a17dbd..2e1cd6f 100644 (file)
@@ -176,9 +176,7 @@ _eio_file_eina_ls_heavy(Ecore_Thread *thread, Eio_File_Direct_Ls *async, Eina_It
 
    if (pack) ecore_thread_feedback(thread, pack);
 
-   eio_file_container_set(&async->ls.common, NULL);
-
-   eina_iterator_free(ls);
+   async->ls.ls = ls;
 }
 
 static void
@@ -468,7 +466,8 @@ eio_async_end(void *data, Ecore_Thread *thread EINA_UNUSED)
    Eio_File_Ls *async = data;
 
    async->common.done_cb((void*) async->common.data, &async->common);
-
+   eio_file_container_set(&async->common, NULL);
+   eina_iterator_free(async->ls);
    eio_async_free(async);
 }
 
index 8fd9e7e..8502713 100644 (file)
@@ -275,6 +275,7 @@ struct _Eio_File_Ls
 {
    Eio_File common;
    const char *directory;
+   Eina_Iterator *ls;
 };
 
 struct _Eio_File_Direct_Ls