diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2015-04-09 19:52:08 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2015-04-09 20:01:18 -0400 |
commit | ce1591859351bcdd6917a6a2596d31dbf8312a5b (patch) | |
tree | 60eb737305a76b4f728ed6949b18ecb25f4df7d2 /src/lib/ecore_file/ecore_file_monitor_inotify.c | |
parent | c1c471de9c3c7085ebee04bd894222e3b8c5acf2 (diff) |
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.c | 15 |
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 | |||
47 | static void _ecore_file_monitor_inotify_print(char *file, int mask); | 47 | static void _ecore_file_monitor_inotify_print(char *file, int mask); |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | static Eina_Hash *monitor_hash; | ||
51 | |||
50 | int | 52 | int |
51 | ecore_file_monitor_backend_init(void) | 53 | ecore_file_monitor_backend_init(void) |
52 | { | 54 | { |
@@ -74,6 +76,7 @@ ecore_file_monitor_backend_init(void) | |||
74 | } | 76 | } |
75 | 77 | ||
76 | _inotify_fd_pid = getpid(); | 78 | _inotify_fd_pid = getpid(); |
79 | monitor_hash = eina_hash_int32_new(NULL); | ||
77 | return 1; | 80 | return 1; |
78 | } | 81 | } |
79 | 82 | ||
@@ -140,6 +143,8 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em) | |||
140 | 143 | ||
141 | if (_monitors) | 144 | if (_monitors) |
142 | _monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em))); | 145 | _monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em))); |
146 | if (ECORE_FILE_MONITOR_INOTIFY(em)->wd >= 0) | ||
147 | eina_hash_del_by_key(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd); | ||
143 | 148 | ||
144 | fd = ecore_main_fd_handler_fd_get(_fdh); | 149 | fd = ecore_main_fd_handler_fd_get(_fdh); |
145 | if (ECORE_FILE_MONITOR_INOTIFY(em)->wd) | 150 | if (ECORE_FILE_MONITOR_INOTIFY(em)->wd) |
@@ -181,14 +186,7 @@ _ecore_file_monitor_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd | |||
181 | static Ecore_File_Monitor * | 186 | static Ecore_File_Monitor * |
182 | _ecore_file_monitor_inotify_monitor_find(int wd) | 187 | _ecore_file_monitor_inotify_monitor_find(int wd) |
183 | { | 188 | { |
184 | Ecore_File_Monitor *l; | 189 | return eina_hash_find(monitor_hash, &wd); |
185 | |||
186 | EINA_INLIST_FOREACH(_monitors, l) | ||
187 | { | ||
188 | if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd) | ||
189 | return l; | ||
190 | } | ||
191 | return NULL; | ||
192 | } | 190 | } |
193 | 191 | ||
194 | static void | 192 | static void |
@@ -295,6 +293,7 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path) | |||
295 | ecore_file_monitor_backend_del(em); | 293 | ecore_file_monitor_backend_del(em); |
296 | return 0; | 294 | return 0; |
297 | } | 295 | } |
296 | eina_hash_add(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd, em); | ||
298 | return 1; | 297 | return 1; |
299 | } | 298 | } |
300 | 299 | ||