[PATCH] dbus control interface: dispatch initial messages
Dan Williams
dcbw
Mon Dec 4 20:45:27 PST 2006
For whatever reason, messages that come in right after we've claimed the
bus name but not iterated through the eloop once don't get dispatched.
To fix this, schedule a dispatch timeout immediately after
initialization of our DBus service.
Dan
--- ctrl_iface_dbus.c.dispatch-earlier 2006-12-04 23:18:23.000000000 -0500
+++ ctrl_iface_dbus.c 2006-12-04 23:40:00.000000000 -0500
@@ -751,6 +751,25 @@
/**
+ * dispatch_initial_dbus_messages - Dispatch initial dbus messages after
+ * claiming bus name
+ * @eloop_ctx: the DBusConnection to dispatch on
+ * @timeout_ctx: unused
+ *
+ * If clients are quick to notice that wpa_supplicant claimed its bus name,
+ * there may have been messages that came in before initialization was
+ * all finished. Dispatch those here.
+ */
+static void dispatch_initial_dbus_messages(void *eloop_ctx, void *timeout_ctx)
+{
+ DBusConnection * con = eloop_ctx;
+
+ while (dbus_connection_get_dispatch_status(con) ==
+ DBUS_DISPATCH_DATA_REMAINS)
+ dbus_connection_dispatch(con);
+}
+
+/**
* wpa_supplicant_dbus_ctrl_iface_init - Initialize dbus control interface
* @global: Pointer to global data from wpa_supplicant_init()
* Returns: Pointer to dbus_ctrl_iface date or %NULL on failure
@@ -788,6 +807,16 @@
if (integrate_with_eloop(iface->con, iface))
goto fail;
+ /* Register the message handler for the global dbus interface */
+ if (!dbus_connection_register_object_path(iface->con,
+ WPAS_DBUS_PATH, &wpas_vtable,
+ iface)) {
+ perror("dbus_connection_register_object_path[dbus]");
+ wpa_printf(MSG_ERROR, "Could not set up DBus message "
+ "handler.");
+ goto fail;
+ }
+
/* Register our service with the message bus */
dbus_error_init(&error);
switch (dbus_bus_request_name(iface->con, WPAS_DBUS_SERVICE,
@@ -813,19 +842,18 @@
if (ret != 0)
goto fail;
- /* Register the message handler for the global dbus interface */
- if (!dbus_connection_register_object_path(iface->con,
- WPAS_DBUS_PATH, &wpas_vtable,
- iface)) {
- perror("dbus_connection_register_object_path[dbus]");
- wpa_printf(MSG_ERROR, "Could not set up DBus message "
- "handler.");
- goto fail;
- }
-
wpa_printf(MSG_DEBUG, "Providing DBus service '" WPAS_DBUS_SERVICE
"'.");
+ /* Dispatch initial DBus messages that may have come in since the bus name
+ * was claimed above. Happens when clients are quick to notice the
+ * wpa_supplicant service.
+ *
+ * FIXME: is there a better solution to this problem?
+ */
+ eloop_register_timeout(0, 50, dispatch_initial_dbus_messages,
+ iface->con, NULL);
+
return iface;
fail:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrl-iface-dbus-dispatch-initial.patch
Type: text/x-patch
Size: 2407 bytes
Desc: not available
Url : http://lists.shmoo.com/pipermail/hostap/attachments/20061204/ad84ffef/attachment.bin
More information about the Hostap
mailing list