summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-11-07 15:47:28 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-11-07 16:08:39 -0800
commitfa3e1dc784275cbcd2f0002cf30525528d5a2bc3 (patch)
tree397951b780801eef82615fc4b7084ed124d95d85
parentd125892601c6278bf40624843d637bbc0e1a0cf0 (diff)
evas: rely on ecore to reset evas rendering thread on fork.
-rw-r--r--src/lib/evas/common/evas_thread_render.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c
index 84ea7b4234..c823125f69 100644
--- a/src/lib/evas/common/evas_thread_render.c
+++ b/src/lib/evas/common/evas_thread_render.c
@@ -1,5 +1,6 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2 2
3#include "Ecore.h"
3#include <assert.h> 4#include <assert.h>
4 5
5static Eina_Thread evas_thread_worker; 6static Eina_Thread evas_thread_worker;
@@ -180,6 +181,43 @@ out:
180 return NULL; 181 return NULL;
181} 182}
182 183
184static void
185evas_thread_fork_reset(void *data EINA_UNUSED)
186{
187 if (!eina_lock_new(&evas_thread_queue_lock))
188 {
189 CRI("Could not create draw thread lock (%m)");
190 goto on_error;
191 }
192 if (!eina_condition_new(&evas_thread_queue_condition, &evas_thread_queue_lock))
193 {
194 CRI("Could not create draw thread condition (%m)");
195 goto on_error;
196 }
197
198 if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, -1,
199 evas_thread_worker_func, NULL))
200 {
201 CRI("Could not recreate draw thread.");
202 goto on_error;
203 }
204
205 return ;
206
207 on_error:
208 eina_lock_free(&evas_thread_queue_lock);
209 eina_condition_free(&evas_thread_queue_condition);
210
211 evas_thread_worker = 0;
212
213 free(evas_thread_queue_cache);
214 evas_thread_queue_cache = NULL;
215 evas_thread_queue_cache_max = 0;
216 eina_inarray_flush(&evas_thread_queue);
217
218 eina_threads_shutdown();
219}
220
183int 221int
184evas_thread_init(void) 222evas_thread_init(void)
185{ 223{
@@ -189,6 +227,8 @@ evas_thread_init(void)
189 exit_thread = EINA_FALSE; 227 exit_thread = EINA_FALSE;
190 evas_thread_exited = 0; 228 evas_thread_exited = 0;
191 229
230 ecore_init();
231
192 if(!eina_threads_init()) 232 if(!eina_threads_init())
193 { 233 {
194 CRI("Could not init eina threads"); 234 CRI("Could not init eina threads");
@@ -215,6 +255,8 @@ evas_thread_init(void)
215 goto fail_on_thread_creation; 255 goto fail_on_thread_creation;
216 } 256 }
217 257
258 ecore_fork_reset_callback_add(evas_thread_fork_reset, NULL);
259
218 return init_count; 260 return init_count;
219 261
220fail_on_thread_creation: 262fail_on_thread_creation:
@@ -227,6 +269,7 @@ fail_on_lock_creation:
227fail_on_eina_thread_init: 269fail_on_eina_thread_init:
228 exit_thread = EINA_TRUE; 270 exit_thread = EINA_TRUE;
229 evas_thread_exited = 1; 271 evas_thread_exited = 1;
272 ecore_shutdown();
230 return --init_count; 273 return --init_count;
231} 274}
232 275
@@ -244,8 +287,13 @@ evas_thread_shutdown(void)
244 if (--init_count) 287 if (--init_count)
245 return init_count; 288 return init_count;
246 289
290 if (!evas_thread_worker)
291 return init_count;
292
247 eina_lock_take(&evas_thread_queue_lock); 293 eina_lock_take(&evas_thread_queue_lock);
248 294
295 ecore_fork_reset_callback_del(evas_thread_fork_reset, NULL);
296
249 exit_thread = EINA_TRUE; 297 exit_thread = EINA_TRUE;
250 eina_condition_signal(&evas_thread_queue_condition); 298 eina_condition_signal(&evas_thread_queue_condition);
251 299
@@ -275,5 +323,7 @@ timeout_shutdown:
275 323
276 eina_threads_shutdown(); 324 eina_threads_shutdown();
277 325
326 ecore_shutdown();
327
278 return 0; 328 return 0;
279} 329}