aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2009-11-12 14:10:45 +0000
committerDaniel P. Berrange <berrange@redhat.com>2009-11-13 11:50:10 +0000
commitfd2090cdb9aa2cef0c678b04a64563242615157a (patch)
treed35080d51d739b52c9a63e595ceccf48439ff8a9
parentFix formatting of XML for an inactive guest (diff)
downloadlibvirt-fd2090cdb9aa2cef0c678b04a64563242615157a.tar.gz
libvirt-fd2090cdb9aa2cef0c678b04a64563242615157a.tar.bz2
libvirt-fd2090cdb9aa2cef0c678b04a64563242615157a.zip
Fix race condition in HAL driver startup
There is a race condition in HAL driver startup where the callback can get triggered before we have finished startup. This then causes a deadlock in the driver. * src/node_device/node_device_hal.c: RElease driver lock before registering DBus callbacks
-rw-r--r--src/node_device/node_device_hal.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 818c7d69d..918a3a9f1 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -742,6 +742,16 @@ static int halDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
goto failure;
}
+ /* Populate with known devices */
+ driverState->privateData = hal_ctx;
+
+ /* We need to unlock state now, since setting these callbacks cause
+ * a dbus RPC call, and while this call is waiting for the reply,
+ * a signal may already arrive, triggering the callback and thus
+ * requiring the lock !
+ */
+ nodeDeviceUnlock(driverState);
+
/* Register HAL event callbacks */
if (!libhal_ctx_set_device_added(hal_ctx, device_added) ||
!libhal_ctx_set_device_removed(hal_ctx, device_removed) ||
@@ -753,10 +763,6 @@ static int halDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
goto failure;
}
- /* Populate with known devices */
- driverState->privateData = hal_ctx;
-
- nodeDeviceUnlock(driverState);
udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
if (udi == NULL) {
VIR_ERROR0("libhal_get_all_devices failed\n");