From: YoungHun Kim Date: Fri, 26 Jan 2018 01:47:22 +0000 (+0900) Subject: Update the race condition of server state X-Git-Tag: submit/tizen/20180202.020558~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94fd056c17dcae0b20f2b9b235d00007e0df1c4e;p=platform%2Fcore%2Fmultimedia%2Fmmsvc-core.git Update the race condition of server state Change-Id: I35d592a2bc92b8390291e59fc94b57eb56f255a4 --- diff --git a/packaging/mused.spec b/packaging/mused.spec index bcabc5c..4436558 100644 --- a/packaging/mused.spec +++ b/packaging/mused.spec @@ -1,6 +1,6 @@ Name: mused Summary: A multimedia daemon -Version: 0.3.29 +Version: 0.3.30 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/server/include/muse_server_private.h b/server/include/muse_server_private.h index 0fa5b2f..ce22068 100644 --- a/server/include/muse_server_private.h +++ b/server/include/muse_server_private.h @@ -99,6 +99,7 @@ int ms_kill_thread(int signo); gboolean ms_init_bufmgr(void); void ms_deinit_bufmgr(void); void ms_cmd_dispatch_foreach_func(gpointer data, gpointer user_data); +void ms_set_state(ms_state_e state); #ifdef __cplusplus } diff --git a/server/src/muse_server_private.c b/server/src/muse_server_private.c index 8312bdf..0338c75 100644 --- a/server/src/muse_server_private.c +++ b/server/src/muse_server_private.c @@ -434,6 +434,18 @@ gpointer _ms_diag_thread(gpointer data) return NULL; } +static void _ms_lock_state(void) +{ + g_return_if_fail(muse_server); + g_mutex_lock(&muse_server->state_lock); +} + +static void _ms_unlock_state(void) +{ + g_return_if_fail(muse_server); + g_mutex_unlock(&muse_server->state_lock); +} + void ms_init(void) { int idx; @@ -642,7 +654,8 @@ int ms_run(void) #ifdef MUSE_USE_LWIPC _ms_wait_event(); - muse_server->state = MUSE_SERVER_STATE_READY; + + ms_set_state(MUSE_SERVER_STATE_READY); if (LwipcEventDone(MUSE_SERVER_READY) < 0) LOGE("Fail to send server ready done event"); @@ -650,8 +663,9 @@ int ms_run(void) ready_fd = creat(MUSE_SERVER_READY, 0644); if (muse_core_fd_is_valid(ready_fd)) { LOGD("MUSE_SERVER_READY(%s) file was created", MUSE_SERVER_READY); + close(ready_fd); - muse_server->state = MUSE_SERVER_STATE_READY; + ms_set_state(MUSE_SERVER_STATE_READY); } else { LOGE("[%d] Fail to create MUSE_SERVER_READY(%s)", ready_fd, MUSE_SERVER_READY); } @@ -738,9 +752,7 @@ void ms_respawn(int signo) g_return_if_fail(muse_server); - _ms_lock_state(); - muse_server->state = MUSE_SERVER_STATE_IDLE; - _ms_unlock_state(); + ms_set_state(MUSE_SERVER_STATE_IDLE); ms_kill_thread(signo); } @@ -764,18 +776,6 @@ void ms_get_cur_time(char *time_buf) snprintf(time_buf, MUSE_LOG_MSG_LEN, "%s.%03ld", cur_time, tv.tv_usec / 1000); } -void _ms_lock_state(void) -{ - g_return_if_fail(muse_server); - g_mutex_lock(&muse_server->state_lock); -} - -void _ms_unlock_state(void) -{ - g_return_if_fail(muse_server); - g_mutex_unlock(&muse_server->state_lock); -} - void ms_log_process_info(int pid) { char cmd[MUSE_MSG_LEN_MAX]; @@ -842,3 +842,12 @@ void ms_cmd_dispatch_foreach_func(gpointer data, gpointer user_data) muse_server_set_user_data(m, NULL); } +void ms_set_state(ms_state_e state) +{ + g_return_if_fail(muse_server); + + g_mutex_lock(&muse_server->state_lock); + muse_server->state = state; + g_mutex_unlock(&muse_server->state_lock); +} + diff --git a/server/src/muse_server_security.c b/server/src/muse_server_security.c index e05e6ad..81dd5cc 100644 --- a/server/src/muse_server_security.c +++ b/server/src/muse_server_security.c @@ -143,11 +143,11 @@ bool ms_security_is_privilege_granted(ms_security_t *security, int fd, const cha ret = cynara_check((cynara *)security->p_cynara, client, session, user, privilege); switch (ret) { case CYNARA_API_ACCESS_ALLOWED: - LOGD("[CYNARA] Check (client = %s, session = %s, user = %s, privilege = %s )" + LOGD("[CYNARA] Check (client = %s, session = %s, user = %s, privilege = %s)" "=> access allowed", client, session, user, privilege); break; case CYNARA_API_ACCESS_DENIED: - LOGD("[CYNARA] Check (client = %s, session = %s, user = %s, privilege = %s )" + LOGE("[CYNARA] Check (client = %s, session = %s, user = %s, privilege = %s)" "=> access denied", client, session, user, privilege); break; default: diff --git a/server/src/muse_server_workqueue.c b/server/src/muse_server_workqueue.c index fab2258..d06a58f 100644 --- a/server/src/muse_server_workqueue.c +++ b/server/src/muse_server_workqueue.c @@ -49,7 +49,6 @@ static void *_ms_workqueue_worker_function(void *ptr) pthread_mutex_unlock(&worker->workqueue->jobs_mutex); - /* Execute the job. */ if (!job->job_function(job)) { snprintf(err_msg, sizeof(err_msg), "Error - Execute the workqueue job, Restart muse server..."); LOGE("%s", err_msg);