aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_file/ecore_file_monitor_inotify.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2015-04-09 19:52:08 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2015-04-09 20:01:18 -0400
commitce1591859351bcdd6917a6a2596d31dbf8312a5b (patch)
tree60eb737305a76b4f728ed6949b18ecb25f4df7d2 /src/lib/ecore_file/ecore_file_monitor_inotify.c
parentEctor: clean up makefile a bit. (diff)
downloadefl-ce1591859351bcdd6917a6a2596d31dbf8312a5b.tar.gz
ecore-file: use hash for finding monitors
this should hugely improve the speed of file monitor event processing; in my test case, 800,000+ monitors were present and the application was entirely unable to process them
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_inotify.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/ecore_file/ecore_file_monitor_inotify.c b/src/lib/ecore_file/ecore_file_monitor_inotify.c
index b2104f32fe..e6847ddb7b 100644
--- a/src/lib/ecore_file/ecore_file_monitor_inotify.c
+++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c
@@ -47,6 +47,8 @@ static int _ecore_file_monitor_inotify_monitor(Ecore_File_Monito
static void _ecore_file_monitor_inotify_print(char *file, int mask);
#endif
+static Eina_Hash *monitor_hash;
+
int
ecore_file_monitor_backend_init(void)
{
@@ -74,6 +76,7 @@ ecore_file_monitor_backend_init(void)
}
_inotify_fd_pid = getpid();
+ monitor_hash = eina_hash_int32_new(NULL);
return 1;
}
@@ -140,6 +143,8 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em)
if (_monitors)
_monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em)));
+ if (ECORE_FILE_MONITOR_INOTIFY(em)->wd >= 0)
+ eina_hash_del_by_key(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd);
fd = ecore_main_fd_handler_fd_get(_fdh);
if (ECORE_FILE_MONITOR_INOTIFY(em)->wd)
@@ -181,14 +186,7 @@ _ecore_file_monitor_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd
static Ecore_File_Monitor *
_ecore_file_monitor_inotify_monitor_find(int wd)
{
- Ecore_File_Monitor *l;
-
- EINA_INLIST_FOREACH(_monitors, l)
- {
- if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd)
- return l;
- }
- return NULL;
+ return eina_hash_find(monitor_hash, &wd);
}
static void
@@ -295,6 +293,7 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path)
ecore_file_monitor_backend_del(em);
return 0;
}
+ eina_hash_add(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd, em);
return 1;
}