trivial: Do not set up the backends if there is no coldplug

This speeds up fu-self-test, but more importantly fixes a intermittent
'ninja check' failure when a host USB device disconnects at exactly the
wrong time.

The FuUsbBackend code is unusual in that the setup() code sets up a
context (with a thread) which takes up to 2 seconds to timeout.
This commit is contained in:
Richard Hughes 2021-08-02 16:34:27 +01:00
parent 8f19ea75d3
commit 7a1d547128

View File

@ -6670,24 +6670,26 @@ fu_engine_load (FuEngine *self, FuEngineLoadFlags flags, GError **error)
fu_context_add_firmware_gtype (self->ctx, "ifd-firmware", FU_TYPE_IFD_FIRMWARE); fu_context_add_firmware_gtype (self->ctx, "ifd-firmware", FU_TYPE_IFD_FIRMWARE);
/* set up backends */ /* set up backends */
if (flags & FU_ENGINE_LOAD_FLAG_COLDPLUG) {
for (guint i = 0; i < self->backends->len; i++) { for (guint i = 0; i < self->backends->len; i++) {
FuBackend *backend = g_ptr_array_index (self->backends, i); FuBackend *backend = g_ptr_array_index(self->backends, i);
g_autoptr(GError) error_backend = NULL; g_autoptr(GError) error_backend = NULL;
if (!fu_backend_setup (backend, &error_backend)) { if (!fu_backend_setup(backend, &error_backend)) {
g_debug ("failed to setup backend %s: %s", g_debug("failed to setup backend %s: %s",
fu_backend_get_name (backend), fu_backend_get_name(backend),
error_backend->message); error_backend->message);
continue; continue;
} }
backend_cnt++; backend_cnt++;
} }
if (backend_cnt == 0) { if (backend_cnt == 0) {
g_set_error_literal (error, g_set_error_literal(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"all backends failed setup"); "all backends failed setup");
return FALSE; return FALSE;
} }
}
/* delete old data files */ /* delete old data files */
if (!fu_engine_cleanup_state (error)) { if (!fu_engine_cleanup_state (error)) {