diff options
-rw-r--r-- | client/src/muse_client.c | 2 | ||||
-rw-r--r-- | packaging/mused.spec | 2 | ||||
-rw-r--r-- | server/src/muse_server_ipc.c | 4 | ||||
-rw-r--r-- | server/src/muse_server_module.c | 2 | ||||
-rw-r--r-- | server/src/muse_server_private.c | 65 |
5 files changed, 51 insertions, 24 deletions
diff --git a/client/src/muse_client.c b/client/src/muse_client.c index 326823d..783360c 100644 --- a/client/src/muse_client.c +++ b/client/src/muse_client.c @@ -166,7 +166,7 @@ static int _mc_new(muse_channel_e channel) if ((ret = connect(sock_fd, (struct sockaddr *)&address, len)) < 0) { strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX); - LOGE("[Critical Error] connect failure : %s", err_msg); + LOGE("[Critical Error : %d] connect failure : %s", errno, err_msg); close(sock_fd); return ret; } diff --git a/packaging/mused.spec b/packaging/mused.spec index a7eb706..86112f2 100644 --- a/packaging/mused.spec +++ b/packaging/mused.spec @@ -1,6 +1,6 @@ Name: mused Summary: A multimedia daemon -Version: 0.3.19 +Version: 0.3.20 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/server/src/muse_server_ipc.c b/server/src/muse_server_ipc.c index d73de41..028a617 100644 --- a/server/src/muse_server_ipc.c +++ b/server/src/muse_server_ipc.c @@ -123,15 +123,13 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data) g_mutex_lock(&dispatch_lock); if (muse_core_msg_object_get_value(MSG_KEY_MODULE_INDEX, jobj, MUSE_TYPE_INT, &idx)) { m->idx = idx; - LOGW("client module %s", ms_get_instance()->conf->host[m->idx]); if (_ms_ipc_module_instance_creation_is_allowed(idx) == FALSE) { ms_cmd_dispatch(m, MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE); g_mutex_unlock(&dispatch_lock); ms_exit_worker(m); } - if (muse_core_msg_object_get_value(MSG_KEY_PID, jobj, MUSE_TYPE_INT, &pid) && m->pid != pid) { + if (muse_core_msg_object_get_value(MSG_KEY_PID, jobj, MUSE_TYPE_INT, &pid) && m->pid != pid) LOGW("connected pid [%d] msg [%d] is different", m->pid, pid); - } ms_connection_register(m); m->is_create_api_called = true; m->ch[MUSE_CHANNEL_MSG].dll_handle = ms_module_open(idx); diff --git a/server/src/muse_server_module.c b/server/src/muse_server_module.c index c093548..4c7b47f 100644 --- a/server/src/muse_server_module.c +++ b/server/src/muse_server_module.c @@ -40,7 +40,7 @@ static gboolean _ms_module_dispatch_timeout_callback(gpointer data) idx = m->idx; disp_api = m->last_cmd; timeout = ms_module_get_timeout(idx, disp_api); - snprintf(err_msg, sizeof(err_msg), "[DEADLOCK] %s {%d}'s dispatcher (%d) does not retrun value within (%d) second", + snprintf(err_msg, sizeof(err_msg), "[DEADLOCK] %s (pid %d)'s dispatcher (%d) does not return value within (%d) second", ms_get_instance()->conf->host[idx], m->pid, disp_api, timeout); LOGE("%s", err_msg); diff --git a/server/src/muse_server_private.c b/server/src/muse_server_private.c index ef697f8..2991517 100644 --- a/server/src/muse_server_private.c +++ b/server/src/muse_server_private.c @@ -242,9 +242,10 @@ static gboolean _ms_connection_handler(GIOChannel *source, GIOCondition conditio char err_msg[MUSE_MSG_LEN_MAX] = {'\0',}; muse_module_h m = NULL; muse_module_h peeked_m = NULL; + muse_module_h candidate_m = NULL; intptr_t module_addr = 0; ms_workqueue_job_t *job = NULL; - GQueue *instance_queue; + GQueue *instance_queue = NULL; LOGI("Enter"); @@ -270,7 +271,7 @@ static gboolean _ms_connection_handler(GIOChannel *source, GIOCondition conditio return FALSE; } - LOGI("server: %d client: %d", server_sockfd, client_sockfd); + LOGI("server : %d client [%d] : %d", server_sockfd, channel, client_sockfd); pid = _ms_get_pid(client_sockfd); @@ -286,25 +287,47 @@ static gboolean _ms_connection_handler(GIOChannel *source, GIOCondition conditio instance_queue = ms_get_instance()->connection->instance_queue; length = g_queue_get_length(instance_queue); + _ms_get_module_addr(client_sockfd, &module_addr); + + m = (muse_module_h)module_addr; + for (idx = 0; idx < length; idx++) { peeked_m = (muse_module_h)g_queue_peek_nth(instance_queue, idx); - if (peeked_m->pid == pid) { - SECURE_LOGI("instance #%d - %s %p (%d)", idx, muse_server->conf->host[peeked_m->idx], peeked_m, peeked_m->pid); - m = peeked_m; - m->ch[MUSE_CHANNEL_DATA].sock_fd = client_sockfd; - break; + if (peeked_m->pid != pid) + continue; + + if (!m) { + if (candidate_m) { + LOGE("muse-server can't support the error case which threre are several modules now"); + goto out; + } + + if (!muse_core_fd_is_valid(peeked_m->ch[MUSE_CHANNEL_DATA].sock_fd)) + candidate_m = peeked_m; + else + SECURE_LOGW("already paired module %p", peeked_m); + + continue; } - } - /* we can remove below when client don't send msg of module addr because it is able to module addr with using _ms_get_pid */ - _ms_get_module_addr(client_sockfd, &module_addr); - if (m) + if (m != peeked_m) + continue; + + if (muse_core_fd_is_valid(m->ch[MUSE_CHANNEL_DATA].sock_fd)) { + SECURE_LOGE("[%d] %s pid %d %p you had better check if instance destroy completed properly", client_sockfd, muse_server->conf->host[m->idx], pid, m); + goto out; + } + + m->ch[MUSE_CHANNEL_DATA].sock_fd = client_sockfd; SECURE_LOGI("%s (pid %d) module : %p module addr from client : %p", muse_server->conf->host[m->idx], pid, m, module_addr); - } + break; + } - if (m == NULL) { - LOGW("[%d] pid %d channel %d failed to get module addr for muse_module_t", pid, client_sockfd, channel); - goto out; + if (candidate_m) { + m = candidate_m; + m->ch[MUSE_CHANNEL_DATA].sock_fd = client_sockfd; + SECURE_LOGW("[%d] %s pid %d %p restore module address at the only one null data channel", client_sockfd, muse_server->conf->host[m->idx], pid, m); + } } job = malloc(sizeof(ms_workqueue_job_t)); @@ -326,8 +349,14 @@ static gboolean _ms_connection_handler(GIOChannel *source, GIOCondition conditio out: close(server_sockfd); close(client_sockfd); - if (channel == MUSE_CHANNEL_MSG) - MUSE_FREE(m); + + if (m) { + if (channel == MUSE_CHANNEL_MSG) + free(m); + else + muse_core_connection_close(m->ch[MUSE_CHANNEL_MSG].sock_fd); + } + MUSE_FREE(job); _ms_unlock_state(); @@ -467,7 +496,7 @@ int ms_deinit(void) g_mutex_clear(&muse_server->state_lock); - for (idx = 0; idx < muse_server->conf->host_cnt; idx++) + for (idx = 0; idx < muse_server->conf->host_cnt; idx++) ms_module_deinit(muse_server->module[idx]); ms_workqueue_deinit(muse_server->workqueue); |