summaryrefslogtreecommitdiff
path: root/src/lib/eio/eio_model.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-07-10 09:43:55 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-07-10 09:43:55 -0400
commit35210b553dce1f2fda7090025318e34919c47712 (patch)
tree67d0576ef72693894c13f407c659b364360c8d53 /src/lib/eio/eio_model.c
parentb27ecc58ddd05465b441682e2a20fd06f66a6c48 (diff)
eio_model: Fix deleting files that don't have assigned types yet
Summary: Trying to delete a file from a creation notification callback can fail. Sometimes the eio model test would sit forever in select() waiting for events that will never occur because of this. This happens since d84a268a71b09d585f1672b44ade698d7babe28d broke deleting of files that haven't yet been assigned a type. Before this commit a delete_me flag would be set before attempting to build a stat buf asynchronously, and then on completion the file would be deleted. I think this was changed because that could potentially race with other async calls and delete the file sooner than expected. So instead of reverting I've made a special delete path that shouldn't race with non-delete paths. Reviewers: devilhorns, zmike Reviewed By: zmike Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6543
Diffstat (limited to 'src/lib/eio/eio_model.c')
-rw-r--r--src/lib/eio/eio_model.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index 9baec99..3b3c2be 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -331,6 +331,19 @@ _eio_build_st_done(void *data, Eio_File *handler EINA_UNUSED, const Eina_Stat *s
331} 331}
332 332
333static void 333static void
334_eio_build_st_done_clobber(void *data, Eio_File *handler, const Eina_Stat *stat)
335{
336 Eio_Model *model = data;
337 Eio_Model *parent;
338
339 efl_ref(model);
340 _eio_build_st_done(data, handler, stat);
341 parent = efl_parent_get(model);
342 efl_model_child_del(parent, model);
343 efl_unref(model);
344}
345
346static void
334_eio_build_st_error(void *data, Eio_File *handler EINA_UNUSED, int error) 347_eio_build_st_error(void *data, Eio_File *handler EINA_UNUSED, int error)
335{ 348{
336 Eio_Model *model = data; 349 Eio_Model *model = data;
@@ -345,6 +358,19 @@ _eio_build_st_error(void *data, Eio_File *handler EINA_UNUSED, int error)
345} 358}
346 359
347static void 360static void
361_eio_build_st_error_clobber(void *data, Eio_File *handler, int error)
362{
363 Eio_Model *model = data;
364 Eio_Model *parent;
365
366 efl_ref(model);
367 _eio_build_st_error(data, handler, error);
368 parent = efl_parent_get(model);
369 efl_model_child_del(parent, model);
370 efl_unref(model);
371}
372
373static void
348_eio_build_st(const Eio_Model *model, Eio_Model_Data *pd) 374_eio_build_st(const Eio_Model *model, Eio_Model_Data *pd)
349{ 375{
350 if (pd->st) return ; 376 if (pd->st) return ;
@@ -354,6 +380,19 @@ _eio_build_st(const Eio_Model *model, Eio_Model_Data *pd)
354 pd->request.stat = eio_file_direct_stat(pd->path, _eio_build_st_done, _eio_build_st_error, efl_ref(model)); 380 pd->request.stat = eio_file_direct_stat(pd->path, _eio_build_st_done, _eio_build_st_error, efl_ref(model));
355} 381}
356 382
383static void
384_eio_build_st_then_clobber(const Eio_Model *model, Eio_Model_Data *pd)
385{
386 if (pd->st) return ;
387 if (pd->request.stat) return ;
388 if (pd->error) return ;
389
390 pd->request.stat = eio_file_direct_stat(pd->path,
391 _eio_build_st_done_clobber,
392 _eio_build_st_error_clobber,
393 efl_ref(model));
394}
395
357static Eina_List *delayed_queue = NULL; 396static Eina_List *delayed_queue = NULL;
358 397
359static void 398static void
@@ -853,8 +892,7 @@ _eio_model_efl_model_child_del(Eo *obj EINA_UNUSED,
853 892
854 if (type == EINA_FILE_UNKNOWN) 893 if (type == EINA_FILE_UNKNOWN)
855 { 894 {
856 child_pd->delete_me = EINA_TRUE; 895 _eio_build_st_then_clobber(child, child_pd);
857 _eio_build_st(child, child_pd);
858 return ; 896 return ;
859 } 897 }
860 898