Add new API to get fds 18/200218/5
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 20 Feb 2019 08:13:13 +0000 (17:13 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 21 Feb 2019 04:53:45 +0000 (13:53 +0900)
- The API is existed to get only one fd.

[Version] 0.3.70
[Profile] Common
[Issue Type] Update
[Dependency module] N/A

Change-Id: Ie4a53d591ada37b4a953ddace4d4478ac8787276
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
core/include/muse_core_internal.h
packaging/mused.spec
server/include/muse_server.h
server/src/muse_server.c
server/src/muse_server_ipc.c

index 614eca5..df028a8 100644 (file)
@@ -132,7 +132,7 @@ typedef enum {
 typedef struct muse_channel_info {
        GThread *data_thread;
        int sock_fd;
-       int tbm_fd;
+       int tbm_fd[MUSE_NUM_FD];
        union {
                GModule *dll_handle;
                struct {
index 5b6ee94..60851b5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mused
 Summary:    A multimedia daemon
-Version:    0.3.69
+Version:    0.3.70
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause
index c54a565..58b981a 100644 (file)
@@ -52,6 +52,7 @@ bool muse_server_ipc_get_data_info(char *data, uint64_t *data_id, int *size);
 intptr_t muse_server_ipc_get_handle(muse_module_h m);
 int muse_server_ipc_set_handle(muse_module_h m, intptr_t handle);
 int muse_server_ipc_get_fd(muse_module_h m, int *fd);
+int muse_server_ipc_get_fds(muse_module_h m, int *fds, int *number);
 int muse_server_ipc_set_fd(muse_module_h m, int fd);
 
 /* security */
index ef9c11c..18d39a8 100644 (file)
@@ -401,7 +401,27 @@ int muse_server_ipc_get_fd(muse_module_h m, int *fd)
        muse_return_val_if_fail(m, MM_ERROR_INVALID_ARGUMENT);
        muse_return_val_if_fail(fd, MM_ERROR_INVALID_ARGUMENT);
 
-       *fd = m->ch[MUSE_CHANNEL_MSG].tbm_fd;
+       *fd = m->ch[MUSE_CHANNEL_MSG].tbm_fd[0];
+       return MM_ERROR_NONE;
+}
+
+int muse_server_ipc_get_fds(muse_module_h m, int *fds, int *number)
+{
+       int i = 0;
+
+       muse_return_val_if_fail(m, MM_ERROR_INVALID_ARGUMENT);
+       muse_return_val_if_fail(fds, MM_ERROR_INVALID_ARGUMENT);
+       muse_return_val_if_fail(number, MM_ERROR_INVALID_ARGUMENT);
+
+       for (i = 0 ; i < MUSE_NUM_FD ; i++) {
+               if (m->ch[MUSE_CHANNEL_MSG].tbm_fd[i] < 0)
+                       break;
+
+               fds[i] = m->ch[MUSE_CHANNEL_MSG].tbm_fd[i];
+       }
+
+       *number = i;
+
        return MM_ERROR_NONE;
 }
 
@@ -414,7 +434,7 @@ int muse_server_ipc_set_fd(muse_module_h m, int fd)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       m->ch[MUSE_CHANNEL_MSG].tbm_fd = fd;
+       m->ch[MUSE_CHANNEL_MSG].tbm_fd[0] = fd;
        return MM_ERROR_NONE;
 }
 
index 932d3bf..a946fd8 100644 (file)
@@ -80,14 +80,13 @@ static gboolean _ms_ipc_module_instance_creation_is_allowed(int module_idx)
 static gpointer _ms_ipc_dispatch_worker(gpointer data)
 {
        int dispatch_ret = MUSE_ERR;
-       int len, api, idx, fd;
+       int len, api, idx, fd, i;
        int parse_len = 0;
        muse_module_h m = NULL;
        gboolean attempt_to_dispatch = TRUE;
        gboolean value = TRUE;
        void *jobj = NULL;
        char err_msg[MUSE_MSG_LEN_MAX] = {'\0',};
-       int tbm_fd[MUSE_NUM_FD] = { MUSE_ERR, };
        int pid = MUSE_ERR;
 
        muse_return_val_if_fail(data, NULL);
@@ -101,7 +100,11 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data)
 
        while (attempt_to_dispatch) {
                memset(m->recv_msg, 0x00, sizeof(m->recv_msg));
-               len = muse_core_msg_recv_fd(fd, m->recv_msg, MUSE_MSG_MAX_LENGTH, tbm_fd);
+
+               for (i = 0 ; i < MUSE_NUM_FD ; i++)
+                       m->ch[MUSE_CHANNEL_MSG].tbm_fd[i] = -1;
+
+               len = muse_core_msg_recv_fd(fd, m->recv_msg, MUSE_MSG_MAX_LENGTH, m->ch[MUSE_CHANNEL_MSG].tbm_fd);
                if (len <= 0) {
                        strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
                        LOGE("[%s] [%d] recv : %s (%d)", ms_config_get_host_name(m->idx), fd, err_msg, errno);
@@ -168,8 +171,6 @@ static gpointer _ms_ipc_dispatch_worker(gpointer data)
                                                LOGE("destroy dispatch failed 0x%x", dispatch_ret);
                                        break;
                                default:
-                                       m->ch[MUSE_CHANNEL_MSG].tbm_fd = tbm_fd[0];
-
                                        if (!m->is_created) {
                                                ms_module_dispatch_lock(m);
                                                if (muse_core_msg_object_get_value(MSG_KEY_MODULE_INDEX, jobj, MUSE_TYPE_INT, &idx)) {