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 cb8e1b9395657496f1e54aeb6a2462c5b34ad128..3004f10476a820c8d0ddd2399e6cf10c5b625b91 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 fec38552879e835a2767fb31ae9ff62d9957d228..70ad9b0b5fb86d8dba12f778aa050adc68807516 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 e37b60625c27374ac35cd88af08d25ae42a6f719..d3759f27e73c6a02a988b4dd17084706f76a24d5 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);