summaryrefslogtreecommitdiff
path: root/src/lib/ecore_file
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
parentc1c471de9c3c7085ebee04bd894222e3b8c5acf2 (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 'src/lib/ecore_file')
-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
47static void _ecore_file_monitor_inotify_print(char *file, int mask); 47static void _ecore_file_monitor_inotify_print(char *file, int mask);
48#endif 48#endif
49 49
50static Eina_Hash *monitor_hash;
51
50int 52int
51ecore_file_monitor_backend_init(void) 53ecore_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
181static Ecore_File_Monitor * 186static 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
194static void 192static 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