From 73a23401ef007cd80297df6546484f3e8a065d2c Mon Sep 17 00:00:00 2001 From: Guillaume Friloux Date: Thu, 9 Oct 2014 21:41:55 +0200 Subject: [PATCH] Fix a bug with using Eio_File handler in main callback. 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 | 7 +++---- src/lib/eio/eio_private.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/eio/eio_file.c b/src/lib/eio/eio_file.c index 0a17dbd03c..2e1cd6fb9e 100644 --- a/src/lib/eio/eio_file.c +++ b/src/lib/eio/eio_file.c @@ -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); } diff --git a/src/lib/eio/eio_private.h b/src/lib/eio/eio_private.h index 8fd9e7e5fb..85027139b9 100644 --- a/src/lib/eio/eio_private.h +++ b/src/lib/eio/eio_private.h @@ -275,6 +275,7 @@ struct _Eio_File_Ls { Eio_File common; const char *directory; + Eina_Iterator *ls; }; struct _Eio_File_Direct_Ls