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,23 +6670,25 @@ 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 */
for (guint i = 0; i < self->backends->len; i++) { if (flags & FU_ENGINE_LOAD_FLAG_COLDPLUG) {
FuBackend *backend = g_ptr_array_index (self->backends, i); for (guint i = 0; i < self->backends->len; i++) {
g_autoptr(GError) error_backend = NULL; FuBackend *backend = g_ptr_array_index(self->backends, i);
if (!fu_backend_setup (backend, &error_backend)) { g_autoptr(GError) error_backend = NULL;
g_debug ("failed to setup backend %s: %s", if (!fu_backend_setup(backend, &error_backend)) {
fu_backend_get_name (backend), g_debug("failed to setup backend %s: %s",
error_backend->message); fu_backend_get_name(backend),
continue; error_backend->message);
continue;
}
backend_cnt++;
}
if (backend_cnt == 0) {
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"all backends failed setup");
return FALSE;
} }
backend_cnt++;
}
if (backend_cnt == 0) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"all backends failed setup");
return FALSE;
} }
/* delete old data files */ /* delete old data files */