aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-06-09 16:45:53 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-06-09 18:37:11 -0700
commit4d5bf9286c2c351711ddb35d4a5931197b26e795 (patch)
tree2a82a4fbfc3aba036b0145523e1a1685a8586ce7
parent7c492d65bc07188b2e6b2a1a5b369d852b2f2fa6 (diff)
There are edge conditions in which the media_result verb can be requested before lms_proxy has been initialized which will cause a segfault. This patchset reorders operations to be sure lms_proxy is initialized before running returning from .init() Bug-AGL: SPEC-1496 Change-Id: I160167e95b6e301aaaabc63efe08972976d18a63 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/media-manager.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/binding/media-manager.c b/binding/media-manager.c
index a1f228a..027072c 100644
--- a/binding/media-manager.c
+++ b/binding/media-manager.c
@@ -224,26 +224,23 @@ static int MediaPlayerDBusInit(void)
return -1;
}
- g_signal_connect (MediaPlayerManage.lms_proxy,
- "g-properties-changed",
- G_CALLBACK (on_interface_proxy_properties_changed),
- NULL);
-
return 0;
}
static void *media_event_loop_thread(void *unused)
{
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
- int ret;
- ret = MediaPlayerDBusInit();
- if (ret == 0) {
- LOGD("g_main_loop_run\n");
- g_main_loop_run(loop);
- }
+ if (loop == NULL)
+ return NULL;
- g_main_loop_unref(loop);
+ g_signal_connect (MediaPlayerManage.lms_proxy,
+ "g-properties-changed",
+ G_CALLBACK (on_interface_proxy_properties_changed),
+ NULL);
+
+ LOGD("g_main_loop_run\n");
+ g_main_loop_run(loop);
return NULL;
}
@@ -284,6 +281,7 @@ int MediaPlayerManagerInit() {
pthread_t thread_id;
GFile *file;
GFileMonitor *mon;
+ int ret;
g_mutex_init(&(MediaPlayerManage.m));
@@ -294,9 +292,11 @@ int MediaPlayerManagerInit() {
g_assert(mon != NULL);
g_signal_connect (mon, "changed", G_CALLBACK(unmount_cb), NULL);
- pthread_create(&thread_id, NULL, media_event_loop_thread, NULL);
+ ret = MediaPlayerDBusInit();
+ if (ret == 0)
+ pthread_create(&thread_id, NULL, media_event_loop_thread, NULL);
- return 0;
+ return ret;
}
/*