Changeset View
Changeset View
Standalone View
Standalone View
src/lib/eio/eio_monitor_poll.c
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
61 | static void | 61 | static void | ||
62 | _eio_monitor_fallback_heavy_cb(void *data, Ecore_Thread *thread) | 62 | _eio_monitor_fallback_heavy_cb(void *data, Ecore_Thread *thread) | ||
63 | { | 63 | { | ||
64 | Eio_Monitor_Backend *backend = data; | 64 | Eio_Monitor_Backend *backend = data; | ||
65 | Eina_Iterator *it; | 65 | Eina_Iterator *it; | ||
66 | Eina_Stat *est; | 66 | Eina_Stat *est; | ||
67 | Eina_File_Direct_Info *info; | 67 | Eina_File_Direct_Info *info; | ||
68 | _eio_stat_t st; | 68 | _eio_stat_t st; | ||
69 | Eina_Bool deleted = EINA_FALSE; | ||||
69 | /* FIXME : copy ecore_file_monitor_poll here */ | 70 | /* FIXME : copy ecore_file_monitor_poll here */ | ||
70 | 71 | | |||
71 | if (!backend->initialised) | 72 | if (!backend->initialised) | ||
72 | est = &backend->self; | 73 | est = &backend->self; | ||
73 | else | 74 | else | ||
74 | est = alloca(sizeof (Eina_Stat)); | 75 | est = alloca(sizeof (Eina_Stat)); | ||
75 | 76 | | |||
76 | if (!backend->parent) | 77 | if (!backend->parent) | ||
77 | return; | 78 | return; | ||
78 | 79 | | |||
79 | if (_eio_stat(backend->parent->path, &st)) | 80 | if (_eio_stat(backend->parent->path, &st)) | ||
80 | { | 81 | { | ||
81 | if (backend->initialised && !backend->destroyed) | 82 | if (backend->initialised && !backend->destroyed) | ||
82 | { | 83 | { | ||
83 | ecore_thread_main_loop_begin(); | 84 | ecore_thread_main_loop_begin(); | ||
84 | _eio_monitor_send(backend->parent, backend->parent->path, EIO_MONITOR_SELF_DELETED); | 85 | deleted = backend->delete_me; | ||
86 | if (!deleted) | ||||
87 | _eio_monitor_send(backend->parent, backend->parent->path, EIO_MONITOR_SELF_DELETED); | ||||
85 | ecore_thread_main_loop_end(); | 88 | ecore_thread_main_loop_end(); | ||
86 | backend->destroyed = EINA_TRUE; | 89 | backend->destroyed = EINA_TRUE; | ||
87 | } | 90 | } | ||
88 | return; | 91 | return; | ||
89 | } | 92 | } | ||
90 | 93 | | |||
91 | backend->destroyed = EINA_FALSE; | 94 | backend->destroyed = EINA_FALSE; | ||
92 | 95 | | |||
Show All 34 Lines | 128 | #endif | |||
127 | if (memcmp(est, &backend->self, sizeof (Eina_Stat)) != 0) | 130 | if (memcmp(est, &backend->self, sizeof (Eina_Stat)) != 0) | ||
128 | { | 131 | { | ||
129 | int event = EIO_MONITOR_DIRECTORY_MODIFIED; | 132 | int event = EIO_MONITOR_DIRECTORY_MODIFIED; | ||
130 | 133 | | |||
131 | if (!S_ISDIR(est->mode)) | 134 | if (!S_ISDIR(est->mode)) | ||
132 | /* regular file: eina_file_direct_ls will return NULL */ | 135 | /* regular file: eina_file_direct_ls will return NULL */ | ||
133 | event = EIO_MONITOR_FILE_MODIFIED; | 136 | event = EIO_MONITOR_FILE_MODIFIED; | ||
134 | ecore_thread_main_loop_begin(); | 137 | ecore_thread_main_loop_begin(); | ||
135 | _eio_monitor_send(backend->parent, backend->parent->path, event); | 138 | deleted = backend->delete_me; | ||
139 | if (!deleted) | ||||
140 | _eio_monitor_send(backend->parent, backend->parent->path, event); | ||||
136 | ecore_thread_main_loop_end(); | 141 | ecore_thread_main_loop_end(); | ||
142 | if (deleted) return; | ||||
137 | } | 143 | } | ||
138 | 144 | | |||
139 | it = eina_file_direct_ls(backend->parent->path); | 145 | it = eina_file_direct_ls(backend->parent->path); | ||
140 | EINA_ITERATOR_FOREACH(it, info) | 146 | EINA_ITERATOR_FOREACH(it, info) | ||
141 | { | 147 | { | ||
142 | Eio_Monitor_Stat *cmp; | 148 | Eio_Monitor_Stat *cmp; | ||
143 | Eio_Monitor_Stat buffer; | 149 | Eio_Monitor_Stat buffer; | ||
144 | 150 | | |||
Show All 14 Lines | 162 | if (!backend->initialised) | |||
159 | } | 165 | } | ||
160 | else | 166 | else | ||
161 | { | 167 | { | ||
162 | cmp = eina_hash_find(backend->children, info->path); | 168 | cmp = eina_hash_find(backend->children, info->path); | ||
163 | if (!cmp) | 169 | if (!cmp) | ||
164 | { | 170 | { | ||
165 | /* New file or new directory added */ | 171 | /* New file or new directory added */ | ||
166 | ecore_thread_main_loop_begin(); | 172 | ecore_thread_main_loop_begin(); | ||
167 | _eio_monitor_send(backend->parent, info->path, | 173 | deleted = backend->delete_me; | ||
168 | info->type != EINA_FILE_DIR ? EIO_MONITOR_FILE_CREATED : EIO_MONITOR_DIRECTORY_CREATED); | 174 | if (!deleted) | ||
175 | _eio_monitor_send(backend->parent, info->path, | ||||
176 | info->type != EINA_FILE_DIR ? EIO_MONITOR_FILE_CREATED : EIO_MONITOR_DIRECTORY_CREATED); | ||||
169 | ecore_thread_main_loop_end(); | 177 | ecore_thread_main_loop_end(); | ||
170 | 178 | if (deleted) break; | |||
171 | cmp = malloc(sizeof (Eio_Monitor_Stat)); | 179 | cmp = malloc(sizeof (Eio_Monitor_Stat)); | ||
172 | memcpy(cmp, &buffer, sizeof (Eina_Stat)); | 180 | memcpy(cmp, &buffer, sizeof (Eina_Stat)); | ||
173 | 181 | | |||
174 | eina_hash_add(backend->children, info->path, cmp); | 182 | eina_hash_add(backend->children, info->path, cmp); | ||
175 | } | 183 | } | ||
176 | else if (memcmp(cmp, &buffer, sizeof (Eina_Stat)) != 0) | 184 | else if (memcmp(cmp, &buffer, sizeof (Eina_Stat)) != 0) | ||
177 | { | 185 | { | ||
178 | /* file has been modified */ | 186 | /* file has been modified */ | ||
179 | ecore_thread_main_loop_begin(); | 187 | ecore_thread_main_loop_begin(); | ||
180 | _eio_monitor_send(backend->parent, info->path, | 188 | deleted = backend->delete_me; | ||
181 | info->type != EINA_FILE_DIR ? EIO_MONITOR_FILE_MODIFIED : EIO_MONITOR_DIRECTORY_MODIFIED); | 189 | if (!deleted) | ||
190 | _eio_monitor_send(backend->parent, info->path, | ||||
191 | info->type != EINA_FILE_DIR ? EIO_MONITOR_FILE_MODIFIED : EIO_MONITOR_DIRECTORY_MODIFIED); | ||||
182 | ecore_thread_main_loop_end(); | 192 | ecore_thread_main_loop_end(); | ||
183 | 193 | if (deleted) break; | |||
184 | memcpy(cmp, &buffer, sizeof (Eina_Stat)); | 194 | memcpy(cmp, &buffer, sizeof (Eina_Stat)); | ||
185 | } | 195 | } | ||
186 | } | 196 | } | ||
187 | 197 | | |||
188 | cmp->version = backend->version; | 198 | cmp->version = backend->version; | ||
189 | if (ecore_thread_check(thread)) goto out; | 199 | if (ecore_thread_check(thread)) break; | ||
190 | } | 200 | } | ||
191 | out: | 201 | | ||
192 | if (it) eina_iterator_free(it); | 202 | if (it) eina_iterator_free(it); | ||
ManMower: is out: now a dangling label? | |||||
193 | 203 | | |||
194 | if (backend->initialised && !ecore_thread_check(thread)) | 204 | if (backend->initialised && !ecore_thread_check(thread)) | ||
195 | { | 205 | { | ||
196 | Eina_Hash_Tuple *tuple; | 206 | Eina_Hash_Tuple *tuple; | ||
197 | Eina_Array *arr; | 207 | Eina_Array *arr; | ||
198 | 208 | | |||
199 | it = eina_hash_iterator_tuple_new(backend->children); | 209 | it = eina_hash_iterator_tuple_new(backend->children); | ||
200 | arr = eina_array_new(1); | 210 | arr = eina_array_new(1); | ||
201 | ecore_thread_main_loop_begin(); | 211 | ecore_thread_main_loop_begin(); | ||
202 | 212 | | |||
203 | EINA_ITERATOR_FOREACH(it, tuple) | 213 | EINA_ITERATOR_FOREACH(it, tuple) | ||
204 | { | 214 | { | ||
205 | Eio_Monitor_Stat *cmp = tuple->data; | 215 | Eio_Monitor_Stat *cmp = tuple->data; | ||
206 | 216 | | |||
207 | if (cmp->version != backend->version) | 217 | if (cmp->version != backend->version) | ||
208 | { | 218 | { | ||
219 | deleted = backend->delete_me; | ||||
220 | if (deleted) break; | ||||
209 | _eio_monitor_send(backend->parent, tuple->key, | 221 | _eio_monitor_send(backend->parent, tuple->key, | ||
210 | eio_file_is_dir(&cmp->buffer) ? EIO_MONITOR_DIRECTORY_DELETED : EIO_MONITOR_FILE_DELETED); | 222 | eio_file_is_dir(&cmp->buffer) ? EIO_MONITOR_DIRECTORY_DELETED : EIO_MONITOR_FILE_DELETED); | ||
211 | eina_array_push(arr, tuple->key); | 223 | eina_array_push(arr, tuple->key); | ||
212 | } | 224 | } | ||
213 | } | 225 | } | ||
214 | 226 | | |||
215 | ecore_thread_main_loop_end(); | 227 | ecore_thread_main_loop_end(); | ||
216 | while (eina_array_count(arr)) | 228 | while (eina_array_count(arr)) | ||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |
is out: now a dangling label?