Avoid dispatching if RM is not launched to prevent unnecessary crash 46/203546/7 accepted/tizen/unified/20190422.003831 submit/tizen/20190419.033804
authorYoungHun Kim <yh8004.kim@samsung.com>
Tue, 16 Apr 2019 00:01:28 +0000 (09:01 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Fri, 19 Apr 2019 03:13:40 +0000 (12:13 +0900)
 - Remove duplicate argument
 - Add the service order related with RM

Change-Id: I94b092ae1e3ca57af3ae518b2045b181a8cb260c

packaging/muse-server.service
packaging/mused.spec
server/CMakeLists.txt
server/include/muse_server_module.h
server/src/muse_server_ipc.c
server/src/muse_server_module.c

index 578819a..e8178e3 100644 (file)
@@ -1,6 +1,6 @@
 [Unit]
 Description=muse server
-After=display-manager.service
+After=display-manager.service mm-resource-managerd.service
 
 [Service]
 Type=forking
index 23fe277..2e3fc16 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A multimedia daemon
-Version:    0.3.73
+Version:    0.3.74
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause
@@ -35,6 +35,8 @@ BuildRequires: pkgconfig(storage)
 BuildRequires: pkgconfig(libresourced)
 BuildRequires: pkgconfig(lwipc)
 BuildRequires: pkgconfig(ttrace)
+%else
+BuildRequires: pkgconfig(mm-resource-manager)
 %endif
 %if 0%{?gtests:1}
 BuildRequires: pkgconfig(gmock)
index 9f7db34..22d0608 100644 (file)
@@ -16,6 +16,10 @@ SET(MAIN-SERVER src/muse_server.c)
 SET(dependents "capi-system-info capi-system-runtime-info cynara-client cynara-creds-socket cynara-session")
 SET(dependents ${dependents} " gmodule-2.0 gstreamer-1.0 iniparser libtbm storage libsystemd-daemon")
 
+IF(MUSE_USE_RM_READY)
+SET(dependents ${dependents} " mm-resource-manager")
+ENDIF(MUSE_USE_RM_READY)
+
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${MUSE_SERVER} REQUIRED ${dependents})
 FOREACH(flag ${${MUSE_SERVER}_CFLAGS})
index 8d45ede..2ac4d13 100644 (file)
@@ -46,7 +46,7 @@ void ms_module_deinit(ms_module_t *module);
 GModule *ms_module_open(int idx);
 void ms_module_dispatch_lock(muse_module_h m);
 void ms_module_dispatch_unlock(muse_module_h m);
-int ms_module_dispatch(muse_module_h m, int api);
+int ms_module_dispatch(muse_module_h m);
 gboolean ms_module_close(muse_module_h m);
 gboolean ms_module_get_loaded_dllsym(int idx);
 void ms_module_set_dllsym_value(int idx, const char *name, gpointer value);
index bb7d6e2..f417c70 100644 (file)
@@ -147,7 +147,7 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data)
                                                g_mutex_init(&m->ch[MUSE_CHANNEL_DATA].data_mutex);
                                                g_cond_init(&m->ch[MUSE_CHANNEL_DATA].data_cond);
                                                LOGD("module fd: %d dll_handle: %p", fd, m->ch[MUSE_CHANNEL_MSG].dll_handle);
-                                               dispatch_ret = ms_module_dispatch(m, api);
+                                               dispatch_ret = ms_module_dispatch(m);
                                        }
                                        ms_module_dispatch_unlock(m);
 
@@ -161,7 +161,7 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data)
                                case API_DESTROY:
                                        SECURE_LOGI("DESTROY %p %d", m, fd);
                                        ms_module_dispatch_lock(m);
-                                       dispatch_ret = ms_module_dispatch(m, api);
+                                       dispatch_ret = ms_module_dispatch(m);
                                        ms_module_dispatch_unlock(m);
                                        if (dispatch_ret == MM_ERROR_NONE)
                                                attempt_to_dispatch = FALSE;
@@ -193,7 +193,7 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data)
                                                }
                                        }
 
-                                       ms_module_dispatch(m, api);
+                                       ms_module_dispatch(m);
 
                                        if (!m->is_created) {
                                                SECURE_LOGW("_ms_ipc_module_cleanup [module %p] [loaded value %d]", m, value);
index 21689df..3065e1f 100644 (file)
@@ -20,6 +20,9 @@
  */
 
 #include "muse_server_private.h"
+#ifdef MUSE_USE_RM_READY
+#include "mm_resource_manager.h"
+#endif
 
 static GMutex dllsym_table_lock;
 
@@ -113,7 +116,7 @@ void ms_module_dispatch_unlock(muse_module_h m)
        g_mutex_unlock(&m->dispatch_lock);
 }
 
-int ms_module_dispatch(muse_module_h m, int api)
+int ms_module_dispatch(muse_module_h m)
 {
        int ret = MUSE_ERR;
        guint id = 0;
@@ -121,13 +124,23 @@ int ms_module_dispatch(muse_module_h m, int api)
        gboolean enable_dispatch_timeout_callback = FALSE;
        muse_module_dispatchfunc *dispatcher = NULL;
        ms_module_t *module = NULL;
+       int api = 0;
 
        muse_return_val_if_fail(m, MUSE_ERR);
+       api = m->api;
 
        module = ms_get_module_instance(m->idx);
        muse_return_val_if_fail(module, MUSE_ERR);
        muse_return_val_if_fail(module->dllsym, MUSE_ERR);
-       muse_return_val_if_fail(api <= API_MAX, MUSE_ERR);
+       muse_return_val_if_fail(api < API_MAX, MUSE_ERR);
+
+#ifdef MUSE_USE_RM_READY
+       if (access(MM_RESOURCE_MANAGER_READY, F_OK) != 0) {
+               LOGE("We skip dispatching (%d) due to resource-manager unavailable", api);
+               ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_MANAGER_SHUTDOWN);
+               return MUSE_ERR;
+       }
+#endif
 
        g_mutex_lock(&module->lock);
        g_module_symbol(module->dllsym, DISPATCHER, (gpointer *)&dispatcher);
@@ -142,7 +155,7 @@ int ms_module_dispatch(muse_module_h m, int api)
                enable_dispatch_timeout_callback = _ms_module_enable_dispatch_timeout_callback(api, m);
 
                if (enable_dispatch_timeout_callback)
-                       id = g_timeout_add_seconds((guint)module->disp_timeout[m->api], (GSourceFunc)_ms_module_dispatch_timeout_callback, (gpointer)m);
+                       id = g_timeout_add_seconds((guint)module->disp_timeout[api], (GSourceFunc)_ms_module_dispatch_timeout_callback, (gpointer)m);
 
                ret = dispatcher[api](m);