Commit 9577b6db authored by Ray Strode's avatar Ray Strode Committed by Bastien Nocera
Browse files

main: request name unconditionally at startup

the dbus activation machinery depends on daemons taking a name on
the bus to complete activation without timeouts.

fprintd fails prematurely if there is USB bus (as found in some
virtual machine setups).

This commit moves the bus-name-acquisition code to happen before
the fail-from-no-usb-bus code to keep callers from timing out
when activating fprintd.

https://bugs.freedesktop.org/show_bug.cgi?id=57025
parent 71bc8146
......@@ -316,6 +316,28 @@ int main(int argc, char **argv)
g_log_set_always_fatal (fatal_mask);
}
/* Obtain a connection to the session bus */
fprintd_dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (fprintd_dbus_conn == NULL) {
g_warning("Failed to open connection to bus: %s", error->message);
return 1;
}
driver_proxy = dbus_g_proxy_new_for_name(fprintd_dbus_conn,
DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (!org_freedesktop_DBus_request_name(driver_proxy, FPRINT_SERVICE_NAME,
0, &request_name_ret, &error)) {
g_warning("Failed to get name: %s", error->message);
return 1;
}
if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
g_warning ("Got result code %u from requesting name", request_name_ret);
return 1;
}
/* Load the configuration file,
* and the default storage plugin */
if (!load_conf())
......@@ -338,31 +360,10 @@ int main(int argc, char **argv)
g_print("Launching FprintObject\n");
/* Obtain a connection to the session bus */
fprintd_dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
if (fprintd_dbus_conn == NULL) {
g_warning("Failed to open connection to bus: %s", error->message);
return 1;
}
/* create the one instance of the Manager object to be shared between
* all fprintd users */
manager = fprint_manager_new(no_timeout);
driver_proxy = dbus_g_proxy_new_for_name(fprintd_dbus_conn,
DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
if (!org_freedesktop_DBus_request_name(driver_proxy, FPRINT_SERVICE_NAME,
0, &request_name_ret, &error)) {
g_warning("Failed to get name: %s", error->message);
return 1;
}
if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
g_warning ("Got result code %u from requesting name", request_name_ret);
return 1;
}
g_message("D-Bus service launched with name: %s", FPRINT_SERVICE_NAME);
g_message("entering main loop");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment