When the device enumeration thread finishes it sets the driver->initialized boolean and signals condition to wake up other threads that are waiting for the initialization to complete. Move this code into a separate function so that it can be re-used from other places too. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/node_device/node_device_driver.c | 10 ++++++++++ src/node_device/node_device_driver.h | 2 ++ src/node_device/node_device_udev.c | 5 +---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index bc8a758c1c..2bb83c19f2 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -157,6 +157,16 @@ nodeDeviceUnlock(void) } +void +nodeDeviceInitComplete(void) +{ + nodeDeviceLock(); + driver->initialized = true; + virCondBroadcast(&driver->initCond); + nodeDeviceUnlock(); +} + + static int nodeDeviceInitWait(void) { diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h index 8a935ffed6..7160f551db 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -39,6 +39,8 @@ nodeDeviceLock(void); void nodeDeviceUnlock(void); +void nodeDeviceInitComplete(void); + extern virNodeDeviceDriverStatePtr driver; int diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 20a13211a0..68547c6986 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1984,10 +1984,7 @@ nodeStateInitializeEnumerate(void *opaque) if (nodeDeviceUpdateMediatedDevices() != 0) goto error; - nodeDeviceLock(); - driver->initialized = true; - virCondBroadcast(&driver->initCond); - nodeDeviceUnlock(); + nodeDeviceInitComplete(); return; -- 2.26.3