forked from enlightenment/efl
eio: actually detect when file changed since last monitoring request.
NOTE: Shouldn't I stat and rebuild the notify when the file is deleted and recreated ? Advise welcome. SVN revision: 70879
This commit is contained in:
parent
123185958e
commit
22b8a6103b
|
@ -5,3 +5,7 @@
|
|||
2012-04-30 Jérôme Pinot
|
||||
|
||||
* Fix build out of tree.
|
||||
|
||||
2012-05-09 Cedric Bail
|
||||
|
||||
* Actually test if we are really requesting to monitor the same file.
|
||||
|
|
|
@ -7,6 +7,7 @@ Additions:
|
|||
|
||||
Fixes:
|
||||
- build out of tree.
|
||||
- detect when requesting to monitor a different file with the same name.
|
||||
|
||||
Improvements:
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ static pid_t _monitor_pid = -1;
|
|||
static void
|
||||
_eio_monitor_free(Eio_Monitor *monitor)
|
||||
{
|
||||
eina_hash_del(_eio_monitors, monitor->path, monitor);
|
||||
if (!monitor->delete_me)
|
||||
eina_hash_del(_eio_monitors, monitor->path, monitor);
|
||||
|
||||
if (monitor->exist) eio_file_cancel(monitor->exist);
|
||||
|
||||
|
@ -262,6 +263,7 @@ EAPI Eio_Monitor *
|
|||
eio_monitor_stringshared_add(const char *path)
|
||||
{
|
||||
Eio_Monitor *monitor;
|
||||
struct stat st;
|
||||
|
||||
if (_monitor_pid == -1) return NULL;
|
||||
|
||||
|
@ -271,17 +273,28 @@ eio_monitor_stringshared_add(const char *path)
|
|||
eio_monitor_init();
|
||||
}
|
||||
|
||||
if (stat(path, &st) != 0) return NULL;
|
||||
|
||||
monitor = eina_hash_find(_eio_monitors, path);
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
EINA_REFCOUNT_REF(monitor);
|
||||
return monitor;
|
||||
if (st.st_mtime != monitor->mtime)
|
||||
{
|
||||
monitor->delete_me = EINA_TRUE;
|
||||
eina_hash_del(_eio_monitors, monitor->path, monitor);
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_REFCOUNT_REF(monitor);
|
||||
return monitor;
|
||||
}
|
||||
}
|
||||
|
||||
monitor = malloc(sizeof (Eio_Monitor));
|
||||
if (!monitor) return NULL;
|
||||
|
||||
monitor->mtime = st.st_mtime;
|
||||
monitor->backend = NULL; // This is needed to avoid race condition
|
||||
monitor->path = eina_stringshare_ref(path);
|
||||
monitor->fallback = EINA_FALSE;
|
||||
|
|
|
@ -411,8 +411,11 @@ struct _Eio_Monitor
|
|||
EINA_REFCOUNT;
|
||||
int error;
|
||||
|
||||
time_t mtime;
|
||||
|
||||
Eina_Bool fallback : 1;
|
||||
Eina_Bool rename : 1;
|
||||
Eina_Bool delete_me : 1;
|
||||
};
|
||||
|
||||
/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */
|
||||
|
|
Loading…
Reference in New Issue