diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2015-04-23 08:54:20 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2015-04-23 08:55:35 -0400 |
commit | ee5c81b736933538b2d611e547ae9de0ca8c4212 (patch) | |
tree | e5d764b50ad62b67acf4015fc6be7792274afb84 /src/lib/ecore_file/ecore_file_monitor_inotify.c | |
parent | bd71d818f9943ca1a8545b932d6496ec7e83d55c (diff) |
ecore-file: use hash list for inotify monitor tracking
inotify reuses watches for multiple instances on the same file, so
keeping a multimap here is necessary to avoid hash collision
fix T2360
Diffstat (limited to '')
-rw-r--r-- | src/lib/ecore_file/ecore_file_monitor_inotify.c | 16 |
1 files changed, 8 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 e6847ddb7b..f86b58d631 100644 --- a/src/lib/ecore_file/ecore_file_monitor_inotify.c +++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c | |||
@@ -40,7 +40,7 @@ static Ecore_File_Monitor *_monitors = NULL; | |||
40 | static pid_t _inotify_fd_pid = -1; | 40 | static pid_t _inotify_fd_pid = -1; |
41 | 41 | ||
42 | static Eina_Bool _ecore_file_monitor_inotify_handler(void *data, Ecore_Fd_Handler *fdh); | 42 | static Eina_Bool _ecore_file_monitor_inotify_handler(void *data, Ecore_Fd_Handler *fdh); |
43 | static Ecore_File_Monitor *_ecore_file_monitor_inotify_monitor_find(int wd); | 43 | static Eina_List *_ecore_file_monitor_inotify_monitor_find(int wd); |
44 | static void _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask); | 44 | static void _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask); |
45 | static int _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path); | 45 | static int _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path); |
46 | #if 0 | 46 | #if 0 |
@@ -144,7 +144,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em) | |||
144 | if (_monitors) | 144 | if (_monitors) |
145 | _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) | 146 | if (ECORE_FILE_MONITOR_INOTIFY(em)->wd >= 0) |
147 | eina_hash_del_by_key(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd); | 147 | eina_hash_list_remove(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd, em); |
148 | 148 | ||
149 | fd = ecore_main_fd_handler_fd_get(_fdh); | 149 | fd = ecore_main_fd_handler_fd_get(_fdh); |
150 | if (ECORE_FILE_MONITOR_INOTIFY(em)->wd) | 150 | if (ECORE_FILE_MONITOR_INOTIFY(em)->wd) |
@@ -156,6 +156,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em) | |||
156 | static Eina_Bool | 156 | static Eina_Bool |
157 | _ecore_file_monitor_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh) | 157 | _ecore_file_monitor_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh) |
158 | { | 158 | { |
159 | Eina_List *l, *ll; | ||
159 | Ecore_File_Monitor *em; | 160 | Ecore_File_Monitor *em; |
160 | char buffer[16384]; | 161 | char buffer[16384]; |
161 | struct inotify_event *event; | 162 | struct inotify_event *event; |
@@ -174,16 +175,15 @@ _ecore_file_monitor_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd | |||
174 | if ((event_size + i) > size) break ; | 175 | if ((event_size + i) > size) break ; |
175 | i += event_size; | 176 | i += event_size; |
176 | 177 | ||
177 | em = _ecore_file_monitor_inotify_monitor_find(event->wd); | 178 | l = _ecore_file_monitor_inotify_monitor_find(event->wd); |
178 | if (!em) continue; | 179 | EINA_LIST_FOREACH(l, ll, em) |
179 | 180 | _ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask); | |
180 | _ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask); | ||
181 | } | 181 | } |
182 | 182 | ||
183 | return ECORE_CALLBACK_RENEW; | 183 | return ECORE_CALLBACK_RENEW; |
184 | } | 184 | } |
185 | 185 | ||
186 | static Ecore_File_Monitor * | 186 | static Eina_List * |
187 | _ecore_file_monitor_inotify_monitor_find(int wd) | 187 | _ecore_file_monitor_inotify_monitor_find(int wd) |
188 | { | 188 | { |
189 | return eina_hash_find(monitor_hash, &wd); | 189 | return eina_hash_find(monitor_hash, &wd); |
@@ -293,7 +293,7 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path) | |||
293 | ecore_file_monitor_backend_del(em); | 293 | ecore_file_monitor_backend_del(em); |
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
296 | eina_hash_add(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd, em); | 296 | eina_hash_list_append(monitor_hash, &ECORE_FILE_MONITOR_INOTIFY(em)->wd, em); |
297 | return 1; | 297 | return 1; |
298 | } | 298 | } |
299 | 299 | ||