From: Volodymyr Brynza Date: Mon, 27 Feb 2017 12:34:06 +0000 (+0200) Subject: Change glib thread creation function to prevent crash in stress testing X-Git-Tag: submit/tizen_3.0/20170329.043647~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6034dbea9f0688b07c36e652b6e71c72e07f47a4;p=platform%2Fupstream%2Fmurphy.git Change glib thread creation function to prevent crash in stress testing Change-Id: I3712b9e397a9b7fc53426ddc378276e02b29062e Signed-off-by: Volodymyr Brynza --- diff --git a/packaging/murphy.spec b/packaging/murphy.spec index 6276f63..6183019 100644 --- a/packaging/murphy.spec +++ b/packaging/murphy.spec @@ -29,7 +29,7 @@ Summary: Resource policy framework Name: murphy Version: 0.0.74 -Release: 6 +Release: 7 License: BSD-2.0 Group: System/Service URL: http://01.org/murphy/ diff --git a/src/common/glib-glue.c b/src/common/glib-glue.c index 68cc1df..21f3dfb 100644 --- a/src/common/glib-glue.c +++ b/src/common/glib-glue.c @@ -448,8 +448,14 @@ int mrp_mainloop_register_with_glib(mrp_mainloop_t *ml, GMainLoop *gml) * glue context isn't default */ GMainContext *def_ctx = g_main_context_default(); GMainContext *loop_ctx = g_main_loop_get_context(glue->gml); - if (loop_ctx && def_ctx != loop_ctx) - glue->worker = g_thread_new(NULL, thread_main, glue); + if (loop_ctx && def_ctx != loop_ctx) { + glue->worker = g_thread_try_new(NULL, thread_main, glue, NULL); + if (glue->worker == NULL) { + g_main_loop_unref(gml); + mrp_free(glue); + return FALSE; + } + } return TRUE; } else {