From: jiyong.min Date: Wed, 8 May 2019 00:33:23 +0000 (+0900) Subject: Rearrange the code. X-Git-Tag: submit/tizen/20190509.095007~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=579fbcbfde5b5b5f6a5e320bc6931f9ee9c95bd4;p=platform%2Fcore%2Fapi%2Fmedia-controller.git Rearrange the code. - After global variables are destroyed, initial values are added - Remove invalid parameter for '__mc_main_destroy_timer()' - Remove unuseful variable 'res' Change-Id: I4e154bf13d9786c9d75d9c5f43b0c800eec1f49b --- diff --git a/svc/daemon/media_controller_main.c b/svc/daemon/media_controller_main.c old mode 100755 new mode 100644 index 009f9d9..c7972b8 --- a/svc/daemon/media_controller_main.c +++ b/svc/daemon/media_controller_main.c @@ -31,16 +31,16 @@ static int g_mc_timer_id = 0; #define MC_MAIN_TIMEOUT_SEC_60 60 -void __mc_main_create_timer(int timer_id); +static void __mc_main_create_timer(void); -gboolean __mc_main_check_connection(gpointer user_data) +static gboolean __mc_main_check_connection(gpointer user_data) { int connection_cnt = 0; connection_cnt = mc_svc_get_connection_cnt(); if ((connection_cnt == -1) || (connection_cnt > 0)) { mc_error("[No-error] Timer is Called but there is working Process, connection_cnt = %d", connection_cnt); - __mc_main_create_timer(g_mc_timer_id); + __mc_main_create_timer(); } else { mc_error("[No-error] Timer is Called. Now Killing mediacontroller process"); g_mc_timer_id = 0; @@ -56,19 +56,20 @@ gboolean __mc_main_check_connection(gpointer user_data) return FALSE; } -void __mc_main_create_timer(int timer_id) +static void __mc_main_create_timer(void) { - if (timer_id > 0) - g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), timer_id)); + if (g_mc_timer_id > 0) + g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), g_mc_timer_id)); GSource *timer_src = g_timeout_source_new_seconds(MC_MAIN_TIMEOUT_SEC_60); g_source_set_callback(timer_src, __mc_main_check_connection, NULL, NULL); g_mc_timer_id = g_source_attach(timer_src, g_main_context_get_thread_default()); } -void __mc_main_destroy_timer() +static void __mc_main_destroy_timer(void) { g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), g_mc_timer_id)); + g_mc_timer_id = 0; } static int __mc_main_create_socket_activation(void) @@ -127,7 +128,7 @@ int main(int argc, char **argv) #ifdef _ON_DEMAND_SOCKET_ACTIVATION /* Create Timer */ - __mc_main_create_timer(g_mc_timer_id); + __mc_main_create_timer(); #endif mc_debug("*** Media Controller Daemon is running ***"); @@ -136,9 +137,10 @@ int main(int argc, char **argv) g_thread_join(svc_thread); g_main_loop_unref(g_mc_mainloop); + g_mc_mainloop = NULL; #ifdef _ON_DEMAND_SOCKET_ACTIVATION - __mc_main_destroy_timer(g_mc_timer_id); + __mc_main_destroy_timer(); #endif mc_cynara_finish(); diff --git a/svc/media_controller_svc.c b/svc/media_controller_svc.c index 24c6fd4..8846121 100644 --- a/svc/media_controller_svc.c +++ b/svc/media_controller_svc.c @@ -532,7 +532,6 @@ static int _mc_service_app_dead_handler(int pid, void *data) gboolean _mc_service_process(gpointer data) { - int res = MEDIA_CONTROLLER_ERROR_NONE; int length_of_queue = 0; int send_msg = MEDIA_CONTROLLER_ERROR_NONE; mc_service_t *_service_data = (mc_service_t*)data; @@ -579,8 +578,7 @@ gboolean _mc_service_process(gpointer data) } else { query_data = strndup(request_msg->msg, request_msg->msg_size); if (query_data != NULL) { - res = mc_db_parse_and_update_db(request_msg->uid, query_data, request_msg->msg_size); - send_msg = res; + send_msg = mc_db_parse_and_update_db(request_msg->uid, query_data, request_msg->msg_size); MC_SAFE_FREE(query_data); } else { send_msg = MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;