Change glib thread creation function to prevent crash in stress testing 72/116672/1
authorVolodymyr Brynza <v.brynza@samsung.com>
Mon, 27 Feb 2017 12:34:06 +0000 (14:34 +0200)
committerVolodymyr Brynza <v.brynza@samsung.com>
Mon, 27 Feb 2017 12:34:06 +0000 (14:34 +0200)
Change-Id: I3712b9e397a9b7fc53426ddc378276e02b29062e
Signed-off-by: Volodymyr Brynza <v.brynza@samsung.com>
packaging/murphy.spec
src/common/glib-glue.c

index 6276f637c5e49bef43c9a81228cda1f61c71ccf2..618301902fe3c57751b3c914bb6fab608e9a69ac 100644 (file)
@@ -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/
index 68cc1dffe291614813461f9877a34f35c14a1547..21f3dfb3df4072c66cfaa2e75b527d19d5b58a19 100644 (file)
@@ -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 {