Removing the watch_all
Drew Moseley
dmoseley at mvista.com
Thu Apr 2 15:58:58 PDT 2009
Hi,
libhal.c and libhal.h define a function libhal_device_property_watch_all()
allowing a callback on any device changed. There is not a corresponding
remove function that I could find. I was triggering a resource fault
(too many watches not surprisingly) in network manager by continually
restarting hal. I added the function shown below and ensured that the
hal_deinit() function in network manager called this and that seemed to
resolve the issue.
Comments? Is there an easier way to do this?
Drew
Signed-off-by: Drew Moseley <dmoseley at mvista.com>
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 9e4b99f..c9d9f74 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -3196,6 +3196,22 @@ libhal_device_property_watch_all (LibHalContext *ctx, DBusError *error)
}
+dbus_bool_t
+libhal_device_property_remove_watch_all (LibHalContext *ctx, DBusError *error)
+{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+
+ dbus_bus_remove_match (ctx->connection,
+ "type='signal',"
+ "interface='org.freedesktop.Hal.Device',"
+ "sender='org.freedesktop.Hal'", error);
+ if (error != NULL && dbus_error_is_set (error)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
/**
* libhal_device_add_property_watch:
* @ctx: the context for the connection to hald
diff --git a/libhal/libhal.h b/libhal/libhal.h
index 99ba191..23c7d13 100644
--- a/libhal/libhal.h
+++ b/libhal/libhal.h
@@ -685,6 +685,11 @@ char **libhal_find_device_by_capability (LibHalContext *ctx,
dbus_bool_t libhal_device_property_watch_all (LibHalContext *ctx,
DBusError *error);
+/* Remove a watch of all devices.
+ */
+dbus_bool_t libhal_device_property_remove_watch_all (LibHalContext *ctx,
+ DBusError *error);
+
/* Add a watch on a device, so the device_property_changed callback is
* invoked when the properties on the given device changes.
*/
More information about the hal
mailing list