summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-06-26 16:39:53 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-06-28 18:08:45 +0200
commit1b18a4e67971486e2c8a6df1dfdc0a3b459d5608 (patch)
treed50cdbfe2bc5224e6a31d6ce4dda07f3ceee6a4b /src/lib/eio
parent4987fd4ab839a4d2acbcf63c056eade681aa92bd (diff)
eio/fallback: fix fallback shutdown when threads exist
threads should not be waited on here during shutdown since these same threads may be waiting on the main loop anyway instead, perform as much deallocation as possible, mark the monitor as deleted, and then set the thread to canceled and allow the thread to clean itself up during its cancel/end callback @fix Differential Revision: https://phab.enlightenment.org/D6440
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/eio_monitor_poll.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/eio/eio_monitor_poll.c b/src/lib/eio/eio_monitor_poll.c
index ec0a2031d3..45e3281615 100644
--- a/src/lib/eio/eio_monitor_poll.c
+++ b/src/lib/eio/eio_monitor_poll.c
@@ -220,6 +220,14 @@ _eio_monitor_fallback_end_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
220 Eio_Monitor_Backend *backend = data; 220 Eio_Monitor_Backend *backend = data;
221 221
222 backend->work = NULL; 222 backend->work = NULL;
223 if (backend->delete_me)
224 {
225 eina_hash_free(backend->children);
226 free(backend);
227 return;
228 }
229 /* indicates eio shutdown is in progress */
230 if (!timer_hash) return;
223 backend->timer = ecore_timer_add(fallback_interval, _eio_monitor_fallback_timer_cb, backend); 231 backend->timer = ecore_timer_add(fallback_interval, _eio_monitor_fallback_timer_cb, backend);
224 eina_hash_set(timer_hash, &backend, backend->timer); 232 eina_hash_set(timer_hash, &backend, backend->timer);
225} 233}
@@ -232,9 +240,12 @@ _eio_monitor_fallback_cancel_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
232 backend->work = NULL; 240 backend->work = NULL;
233 if (backend->delete_me) 241 if (backend->delete_me)
234 { 242 {
243 eina_hash_free(backend->children);
235 free(backend); 244 free(backend);
236 return; 245 return;
237 } 246 }
247 /* indicates eio shutdown is in progress */
248 if (!timer_hash) return;
238 backend->timer = ecore_timer_add(fallback_interval, _eio_monitor_fallback_timer_cb, backend); 249 backend->timer = ecore_timer_add(fallback_interval, _eio_monitor_fallback_timer_cb, backend);
239 eina_hash_set(timer_hash, &backend, backend->timer); 250 eina_hash_set(timer_hash, &backend, backend->timer);
240} 251}
@@ -338,18 +349,16 @@ eio_monitor_fallback_del(Eio_Monitor *monitor)
338 monitor->backend = NULL; 349 monitor->backend = NULL;
339 350
340 if (!backend) return; 351 if (!backend) return;
352 backend->delete_me = EINA_TRUE;
341 353
342 if (backend->work) ecore_thread_cancel(backend->work);
343 354
344 if (backend->timer) ecore_timer_del(backend->timer); 355 if (backend->timer) ecore_timer_del(backend->timer);
345 eina_hash_set(timer_hash, &backend, NULL); 356 eina_hash_set(timer_hash, &backend, NULL);
346 backend->timer = NULL; 357 backend->timer = NULL;
347 if (backend->idler) ecore_idler_del(backend->idler);
348 backend->idler = NULL;
349 358
350 if (backend->work && !ecore_thread_wait(backend->work, 0.3)) 359 if (backend->work)
351 { 360 {
352 backend->delete_me = EINA_TRUE; 361 ecore_thread_cancel(backend->work);
353 return; 362 return;
354 } 363 }
355 364