[glib/1109-no-match-rule] GDBusProxy: add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag



commit f04c36e6e41a9d91187598e7d02f29cfb57edf30
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Fri Nov 27 17:41:47 2015 +0100

    GDBusProxy: add G_DBUS_PROXY_FLAGS_NO_MATCH_RULE flag
    
    D-Bus has an upper limit on number of Match rules and it's rather easy to hit
    with a big number of proxies with signal subscriptions. This happens with
    NetworkManager with hundreds of devices or connection settings. By passing
    G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE to g_dbus_connection_signal_subscribe(), the
    user can call AddMatch with a less granular match instead of a match per every
    proxy.
    
    https://gitlab.gnome.org/GNOME/glib/issues/1109

 gio/gdbusproxy.c | 10 +++++++---
 gio/gioenums.h   |  6 +++++-
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 6d84deced..dfbc56dfc 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -1736,6 +1736,10 @@ static void
 async_initable_init_first (GAsyncInitable *initable)
 {
   GDBusProxy *proxy = G_DBUS_PROXY (initable);
+  GDBusSignalFlags signal_flags = G_DBUS_SIGNAL_FLAGS_NONE;
+
+  if (proxy->priv->flags & G_DBUS_PROXY_FLAGS_NO_MATCH_RULE)
+    signal_flags |= G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE;
 
   if (!(proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES))
     {
@@ -1747,7 +1751,7 @@ async_initable_init_first (GAsyncInitable *initable)
                                             "PropertiesChanged",
                                             proxy->priv->object_path,
                                             proxy->priv->interface_name,
-                                            G_DBUS_SIGNAL_FLAGS_NONE,
+                                            signal_flags,
                                             on_properties_changed,
                                             signal_subscription_ref (proxy->priv->signal_subscription_data),
                                             (GDestroyNotify) signal_subscription_unref);
@@ -1763,7 +1767,7 @@ async_initable_init_first (GAsyncInitable *initable)
                                             NULL,                        /* member */
                                             proxy->priv->object_path,
                                             NULL,                        /* arg0 */
-                                            G_DBUS_SIGNAL_FLAGS_NONE,
+                                            signal_flags,
                                             on_signal_received,
                                             signal_subscription_ref (proxy->priv->signal_subscription_data),
                                             (GDestroyNotify) signal_subscription_unref);
@@ -1778,7 +1782,7 @@ async_initable_init_first (GAsyncInitable *initable)
                                             "NameOwnerChanged",      /* signal name */
                                             "/org/freedesktop/DBus", /* path */
                                             proxy->priv->name,       /* arg0 */
-                                            G_DBUS_SIGNAL_FLAGS_NONE,
+                                            signal_flags,
                                             on_name_owner_changed,
                                             signal_subscription_ref (proxy->priv->signal_subscription_data),
                                             (GDestroyNotify) signal_subscription_unref);
diff --git a/gio/gioenums.h b/gio/gioenums.h
index a83fa71f1..6b888c2fa 100644
--- a/gio/gioenums.h
+++ b/gio/gioenums.h
@@ -1001,6 +1001,9 @@ typedef enum
  * do not ask the bus to launch an owner during proxy initialization, but allow it to be
  * autostarted by a method call. This flag is only meaningful in proxies for well-known names,
  * and only if %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is not also specified.
+ * @G_DBUS_PROXY_FLAGS_NO_MATCH_RULE: Don't actually send the AddMatch D-Bus
+ *    call for this signal subscription.  This gives you more control
+ *    over which match rules you add (but you must add them manually). (Since: 2.60)
  *
  * Flags used when constructing an instance of a #GDBusProxy derived class.
  *
@@ -1013,7 +1016,8 @@ typedef enum
   G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS = (1<<1),
   G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START = (1<<2),
   G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES = (1<<3),
-  G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION = (1<<4)
+  G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION = (1<<4),
+  G_DBUS_PROXY_FLAGS_NO_MATCH_RULE = (1<<5)
 } GDBusProxyFlags;
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]