libgdbus: replace gdbus proxy call with g_dbus_connection_call 27/184527/2 accepted/tizen/5.0/unified/20181102.021930 accepted/tizen/unified/20180724.073404 submit/tizen/20180724.051226 submit/tizen_5.0/20181101.000004
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Wed, 18 Jul 2018 11:15:29 +0000 (20:15 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Wed, 18 Jul 2018 11:31:12 +0000 (20:31 +0900)
Replace g_dbus_proxy_call_with_unix_fd_list_sync with g_dbus_connection_call_with_unix_fd_list_sync.

gdbus proxy is heavy operation - it makes multiple dbus calls to maintain proxy feature.
This functionality is not needed to exchange fd list each other by libgdbus.

Change-Id: I5f7b87614eddfd1a79d7aa82332c97dcc5cc6069
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/libgdbus/dbus-system.c

index 79c97e6..42f061b 100755 (executable)
@@ -1796,7 +1796,6 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply(const char *dest,
        GVariant * var = NULL;
        GVariant * ret = NULL;
        dbus_handle_s *dh = NULL;
-       GDBusProxy *proxy = NULL;
        GUnixFDList *g_infdlist = NULL;
        GUnixFDList *g_outfdlist = NULL;
 
@@ -1818,18 +1817,6 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply(const char *dest,
        if (signature && param)
                var = _append_variant(signature, param);
 
-       proxy = g_dbus_proxy_new_sync(dh->conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dest, path, iface, NULL, &err);
-       if (!proxy) {
-               if (err) {
-                       _E("failed to proxy_new_sync(%s)\n", err->message);
-                       g_error_free(err);
-               } else {
-                       _E("failed to proxy_new_sync\n");
-                       if (var)
-                               g_variant_unref(var);
-               }
-       }
-
        /* append fd */
        if (in_fdlist) {
                g_infdlist = g_unix_fd_list_new_from_array(in_fdlist, in_size);
@@ -1841,14 +1828,18 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply(const char *dest,
                //if (g_unix_fd_list_append(g_infdlist, in_fdlist[0], &err) < 0) {
        }
 
-       ret = g_dbus_proxy_call_with_unix_fd_list_sync(proxy, method, var, G_DBUS_CALL_FLAGS_NONE, -1,
-               g_infdlist, &g_outfdlist, NULL, &err);
+       ret = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
+               dest, path, iface, method, var,
+               NULL, G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               g_infdlist, &g_outfdlist,
+               NULL, &err);
        if (!ret || err) {
                if (err) {
-                       _E("failed to g_dbus_proxy_call_with_unix_fd_list_sync:%s", err->message);
+                       _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:%s", err->message);
                        g_error_free(err);
                } else {
-                       _E("failed to g_dbus_proxy_call_with_unix_fd_list_sync:");
+                       _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:");
                        if (var)
                                g_variant_unref(var);
                        if (g_infdlist)
@@ -1869,8 +1860,6 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply(const char *dest,
 out:
        if (g_outfdlist)
                g_object_unref(g_outfdlist);
-       if (proxy)
-               g_object_unref(proxy);
 
        return ret;
 }
@@ -1888,7 +1877,6 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *d
        GError *err = NULL;
        GVariant * ret = NULL;
        dbus_handle_s *dh = NULL;
-       GDBusProxy *proxy = NULL;
        GUnixFDList *g_infdlist = NULL;
        GUnixFDList *g_outfdlist = NULL;
 
@@ -1907,19 +1895,6 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *d
                return NULL;
        }
 
-       proxy = g_dbus_proxy_new_sync(dh->conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dest, path, iface, NULL, &err);
-       if (!proxy) {
-               if (err) {
-                       _E("failed to proxy_new_sync(%s)\n", err->message);
-                       g_error_free(err);
-               } else {
-                       _E("failed to proxy_new_sync\n");
-                       if (param)
-                               g_variant_unref(param);
-               }
-               goto out;
-       }
-
        /* append fd */
        if (in_fdlist) {
                g_infdlist = g_unix_fd_list_new_from_array(in_fdlist, in_size);
@@ -1932,14 +1907,18 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *d
        }
 
        /* send message */
-       ret = g_dbus_proxy_call_with_unix_fd_list_sync(proxy, method, param, G_DBUS_CALL_FLAGS_NONE, -1,
-               g_infdlist, &g_outfdlist, NULL, &err);
+       ret = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
+               dest, path, iface, method, param,
+               NULL, G_DBUS_CALL_FLAGS_NONE,
+               -1,
+               g_infdlist, &g_outfdlist,
+               NULL, &err);
        if (!ret || err) {
                if (err) {
-                       _E("failed to g_dbus_proxy_call_with_unix_fd_list_sync:%s", err->message);
+                       _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:%s", err->message);
                        g_error_free(err);
                } else {
-                       _E("failed to g_dbus_proxy_call_with_unix_fd_list_sync:");
+                       _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:");
                        if (param)
                                g_variant_unref(param);
                        if (g_infdlist)
@@ -1958,8 +1937,6 @@ GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *d
 out:
        if (g_outfdlist)
                g_object_unref(g_outfdlist);
-       if (proxy)
-               g_object_unref(proxy);
        return ret;
 }