summaryrefslogtreecommitdiff
path: root/src/common/glib-glue.c
diff options
context:
space:
mode:
authorVolodymyr Brynza <v.brynza@samsung.com>2017-02-27 14:34:06 +0200
committerVolodymyr Brynza <v.brynza@samsung.com>2017-02-27 14:34:06 +0200
commit6034dbea9f0688b07c36e652b6e71c72e07f47a4 (patch)
treebdd92d5e800e3b1a085586f588d3b84dd38cd0d5 /src/common/glib-glue.c
parent6b6c10334fe64dbbcf68c8c722ea74f97960e56c (diff)
downloadmurphy-6034dbea9f0688b07c36e652b6e71c72e07f47a4.tar.gz
murphy-6034dbea9f0688b07c36e652b6e71c72e07f47a4.tar.bz2
murphy-6034dbea9f0688b07c36e652b6e71c72e07f47a4.zip
Change glib thread creation function to prevent crash in stress testing
Change-Id: I3712b9e397a9b7fc53426ddc378276e02b29062e Signed-off-by: Volodymyr Brynza <v.brynza@samsung.com>
Diffstat (limited to 'src/common/glib-glue.c')
-rw-r--r--src/common/glib-glue.c10
1 files changed, 8 insertions, 2 deletions
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 {