kdbus: share fd and pool with libdbuspolicy 72/201472/6 accepted/tizen/unified/20190322.075523 submit/tizen/20190321.094448
authorAdrian Szyndela <adrian.s@samsung.com>
Wed, 13 Mar 2019 15:39:26 +0000 (16:39 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Tue, 19 Mar 2019 07:48:23 +0000 (08:48 +0100)
This uses new functionality of libdbuspolicy: using client's pool and fd.
This way libdbuspolicy doesn't have to create its own connection,
and what is more important it doesn't have to create its own 1MB pool.
This is at the cost of using client's pool for receiving responses
to ioctl(KDBUS_CMD_GET_CONN_INFO), which are small.

Change-Id: I183a91196fead179a9fba22fa6418680305d3558

dbus/dbus-transport-kdbus.c
dbus/kdbus-common.c
dbus/kdbus-common.h

index cb8e1b9..3004f10 100755 (executable)
@@ -1226,7 +1226,8 @@ bus_register_kdbus (DBusTransportKdbus *transport,
   dbus_uint64_t flags;
 
 #ifdef LIBDBUSPOLICY
-  void *policy = dbuspolicy1_init (_kdbus_get_path(transport->kdbus));
+  void *policy = dbuspolicy1_init_shared (_kdbus_get_path(transport->kdbus),
+                                          _kdbus_get_fd(transport->kdbus));
   if (NULL == policy)
     {
       dbus_set_error (error,
@@ -1258,6 +1259,10 @@ bus_register_kdbus (DBusTransportKdbus *transport,
       return FALSE;
     }
 
+#ifdef LIBDBUSPOLICY
+  dbuspolicy1_init_set_pool (transport->policy, _kdbus_get_pool(transport->kdbus));
+#endif
+
   transport->my_DBus_unique_name = create_unique_name_from_unique_id (_kdbus_get_id (transport->kdbus));
   if (NULL == transport->my_DBus_unique_name)
     {
@@ -2533,7 +2538,7 @@ capture_org_freedesktop_DBus (DBusTransportKdbus *transport,
            else
              ret = 0;
 
-        } /* id DBUS_INTERFACE_DBUS */
+        } /* if DBUS_INTERFACE_DBUS */
     } /* if DBUS_SERVICE_DBUS */
 
   return ret;
index fec3855..70ad9b0 100755 (executable)
@@ -317,6 +317,12 @@ _kdbus_close (kdbus_t *kdbus)
   return 0;
 }
 
+void *
+_kdbus_get_pool (kdbus_t *kdbus)
+{
+  return kdbus->mmap_ptr;
+}
+
 const char *
 _kdbus_get_path (kdbus_t *kdbus)
 {
index e37b606..d3759f2 100755 (executable)
@@ -67,6 +67,7 @@ void        _kdbus_free                            (kdbus_t *kdbus);
 int         _kdbus_open                            (kdbus_t *kdbus);
 int         _kdbus_close                           (kdbus_t *kdbus);
 
+void       *_kdbus_get_pool                        (kdbus_t *kdbus);
 const char *_kdbus_get_path                        (kdbus_t *kdbus);
 int         _kdbus_get_fd                          (kdbus_t *kdbus);
 __u64       _kdbus_get_id                          (kdbus_t *kdbus);