[PATCH] config: unregister match rule on disconnect. (#27681)

Peter Hutterer peter.hutterer at who-t.net
Tue Apr 20 00:41:16 PDT 2010


On disconnect, HAL doesn't unregister the DBus match rule.
After a lot of server generations, we exceed the number of match rules
allowed for a DBus connection:

[config/hal] couldn't add match rule: org.freedesktop.DBus.Error.LimitsExceeded
(Connection ":1.34" is not allowed to add more match rules (increase limits in
configuration file if required))
[config/hal] cannot detect a HAL startup.

X.Org Bug 27681 <http://bugs.freedesktop.org/show_bug.cgi?id=27681>

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Testcase: run xdpyinfo in a loop.

 config/hal.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/config/hal.c b/config/hal.c
index d3daa84..bb83761 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -43,6 +43,12 @@
 #define LIBHAL_PROP_KEY "input.x11_options."
 #define LIBHAL_XKB_PROP_KEY "input.xkb."
 
+static const char MATCH_RULE[] = "sender='org.freedesktop.DBus',"
+                                 "interface='org.freedesktop.DBus',"
+                                 "type='signal',"
+                                 "path='/org/freedesktop/DBus',"
+                                 "member='NameOwnerChanged'";
+
 
 struct config_hal_info {
     DBusConnection *system_bus;
@@ -429,6 +435,8 @@ disconnect_hook(void *data)
             if (!libhal_ctx_shutdown(info->hal_ctx, &error))
                 LogMessage(X_WARNING, "config/hal: disconnect_hook couldn't shut down context: %s (%s)\n",
                         error.name, error.message);
+
+            dbus_bus_remove_match(info->system_bus, MATCH_RULE, &error);
             dbus_error_free(&error);
         }
         libhal_ctx_free(info->hal_ctx);
@@ -574,11 +582,6 @@ listen_for_startup(DBusConnection *connection, void *data)
 {
     DBusObjectPathVTable vtable = { .message_function = ownerchanged_handler, };
     DBusError error;
-    const char MATCH_RULE[] = "sender='org.freedesktop.DBus',"
-                              "interface='org.freedesktop.DBus',"
-                              "type='signal',"
-                              "path='/org/freedesktop/DBus',"
-                              "member='NameOwnerChanged'";
     int rc = FALSE;
 
     dbus_error_init(&error);
@@ -643,5 +646,6 @@ config_hal_init(void)
 void
 config_hal_fini(void)
 {
+    disconnect_hook(&hal_info);
     config_dbus_core_remove_hook(&hook);
 }
-- 
1.6.6.1



More information about the xorg-devel mailing list