diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-06-09 16:45:53 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-06-09 18:37:11 -0700 |
commit | 4d5bf9286c2c351711ddb35d4a5931197b26e795 (patch) | |
tree | 2a82a4fbfc3aba036b0145523e1a1685a8586ce7 /binding | |
parent | 7c492d65bc07188b2e6b2a1a5b369d852b2f2fa6 (diff) |
binding: mediascanner: fix race condition with dbus and lightmediascannerguppy_6.90.0guppy/6.90.0flounder_5.99.6flounder_5.99.5flounder_5.99.4flounder_5.99.3flounder_5.99.2flounder_5.99.1flounder/5.99.6flounder/5.99.5flounder/5.99.4flounder/5.99.3flounder/5.99.2flounder/5.99.16.90.05.99.65.99.55.99.45.99.35.99.25.99.1
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>
Diffstat (limited to 'binding')
-rw-r--r-- | binding/media-manager.c | 28 |
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; } /* |