Fix RPC-Port function 86/192286/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 2 Nov 2018 04:37:09 +0000 (13:37 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Fri, 2 Nov 2018 07:34:04 +0000 (07:34 +0000)
The parameters of aul_rpc_port_create_socket_pair function are added.

Requires:
 - https://review.tizen.org/gerrit/#/c/192266/ [amd]
 - https://review.tizen.org/gerrit/#/c/192286/ [aul-1]
 - https://review.tizen.org/gerrit/#/c/192287/ [rpc-port]

Change-Id: I577f459e90b93a690b7566f43ee16b7ce4715189
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul_rpc_port.h
src/aul_rpc_port.c

index 3c1af19..5de80c7 100644 (file)
@@ -25,7 +25,8 @@ extern "C" {
 
 int aul_rpc_port_prepare_stub(const char *appid, const char *port_name);
 
-int aul_rpc_port_create_socket_pair(int (*fds)[2]);
+int aul_rpc_port_create_socket_pair(const char *appid, const char *port_name,
+               int (*fds)[2]);
 
 int aul_rpc_port_notify_rpc_finished(void);
 
index 40a1791..2fe6279 100644 (file)
 #include "aul_rpc_port.h"
 #include "aul.h"
 
-API int aul_rpc_port_prepare_stub(const char *appid, const char *port_name)
+static bundle *__create_bundle(const char *appid, const char *port_name)
 {
        bundle *b;
        int r;
 
-       if (!appid || !port_name) {
-               _E("Invalid parameter");
-               return AUL_R_EINVAL;
-       }
-
        b = bundle_create();
        if (!b) {
                _E("Out of memory");
-               return AUL_R_ERROR;
+               return NULL;
        }
 
        r = bundle_add(b, AUL_K_APPID, appid);
        if (r != BUNDLE_ERROR_NONE) {
                _E("Failed to add appid(%s)", appid);
                bundle_free(b);
-               return AUL_R_ERROR;
+               return NULL;
        }
 
        r = bundle_add(b, AUL_K_RPC_PORT, port_name);
        if (r != BUNDLE_ERROR_NONE) {
                _E("Failed to add port_name(%s)", port_name);
                bundle_free(b);
-               return AUL_R_ERROR;
+               return NULL;
+       }
+
+       return b;
+}
+
+API int aul_rpc_port_prepare_stub(const char *appid, const char *port_name)
+{
+       bundle *b;
+       int r;
+
+       if (!appid || !port_name) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
        }
 
+       b = __create_bundle(appid, port_name);
+       if (!b)
+               return AUL_R_ERROR;
+
        r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
                        RPC_PORT_PREPARE_STUB, b, AUL_SOCK_QUEUE);
        if (r < 0) {
@@ -69,23 +81,30 @@ API int aul_rpc_port_prepare_stub(const char *appid, const char *port_name)
        return AUL_R_OK;
 }
 
-API int aul_rpc_port_create_socket_pair(int (*fds)[2])
+API int aul_rpc_port_create_socket_pair(const char *appid,
+               const char *port_name, int (*fds)[2])
 {
+       bundle *b;
        int fd;
        int r;
 
-       if (!fds) {
+       if (!appid || !port_name || !fds) {
                _E("Invalid parameter");
                return AUL_R_EINVAL;
        }
 
-       fd = aul_sock_send_raw(AUL_UTIL_PID, getuid(),
-                       RPC_PORT_CREATE_SOCKET_PAIR, NULL,
-                       0, AUL_SOCK_ASYNC);
+       b = __create_bundle(appid, port_name);
+       if (!b)
+               return AUL_R_ERROR;
+
+       fd = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+                       RPC_PORT_CREATE_SOCKET_PAIR, b, AUL_SOCK_ASYNC);
        if (fd <= 0 || fd > sysconf(_SC_OPEN_MAX)) {
                _E("Failed to send socket pair creation request. err = %d", fd);
+               bundle_free(b);
                return fd;
        }
+       bundle_free(b);
 
        r = aul_sock_recv_reply_sock_fd(fd, fds, 2);
        if (r != 0) {