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 d84a268a71 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
This commit is contained in:
Derek Foreman 2018-07-10 09:43:55 -04:00 committed by Mike Blumenkrantz
parent b27ecc58dd
commit 35210b553d
2 changed files with 40 additions and 3 deletions

View File

@ -330,6 +330,19 @@ _eio_build_st_done(void *data, Eio_File *handler EINA_UNUSED, const Eina_Stat *s
efl_unref(model);
}
static void
_eio_build_st_done_clobber(void *data, Eio_File *handler, const Eina_Stat *stat)
{
Eio_Model *model = data;
Eio_Model *parent;
efl_ref(model);
_eio_build_st_done(data, handler, stat);
parent = efl_parent_get(model);
efl_model_child_del(parent, model);
efl_unref(model);
}
static void
_eio_build_st_error(void *data, Eio_File *handler EINA_UNUSED, int error)
{
@ -344,6 +357,19 @@ _eio_build_st_error(void *data, Eio_File *handler EINA_UNUSED, int error)
efl_unref(model);
}
static void
_eio_build_st_error_clobber(void *data, Eio_File *handler, int error)
{
Eio_Model *model = data;
Eio_Model *parent;
efl_ref(model);
_eio_build_st_error(data, handler, error);
parent = efl_parent_get(model);
efl_model_child_del(parent, model);
efl_unref(model);
}
static void
_eio_build_st(const Eio_Model *model, Eio_Model_Data *pd)
{
@ -354,6 +380,19 @@ _eio_build_st(const Eio_Model *model, Eio_Model_Data *pd)
pd->request.stat = eio_file_direct_stat(pd->path, _eio_build_st_done, _eio_build_st_error, efl_ref(model));
}
static void
_eio_build_st_then_clobber(const Eio_Model *model, Eio_Model_Data *pd)
{
if (pd->st) return ;
if (pd->request.stat) return ;
if (pd->error) return ;
pd->request.stat = eio_file_direct_stat(pd->path,
_eio_build_st_done_clobber,
_eio_build_st_error_clobber,
efl_ref(model));
}
static Eina_List *delayed_queue = NULL;
static void
@ -853,8 +892,7 @@ _eio_model_efl_model_child_del(Eo *obj EINA_UNUSED,
if (type == EINA_FILE_UNKNOWN)
{
child_pd->delete_me = EINA_TRUE;
_eio_build_st(child, child_pd);
_eio_build_st_then_clobber(child, child_pd);
return ;
}

View File

@ -68,7 +68,6 @@ struct _Eio_Model_Data
Eina_Error error;
Eina_Bool listed : 1;
Eina_Bool delete_me : 1;
};
#endif