virNetServerProgram *remoteProgram = NULL;
virNetServerProgram *qemuProgram = NULL;
-volatile bool driversInitialized = false;
+volatile gint driversInitialized = 0;
static void daemonErrorHandler(void *opaque G_GNUC_UNUSED,
virErrorPtr err G_GNUC_UNUSED)
VIR_INFO("Reloading configuration on SIGHUP");
virHookCall(VIR_HOOK_DRIVER_DAEMON, "-",
VIR_HOOK_DAEMON_OP_RELOAD, SIGHUP, "SIGHUP", NULL, NULL);
- if (virStateReload() < 0)
+
+ if (virStateReload() < 0) {
VIR_WARN("Error while reloading drivers");
+ }
+
+ /* Drivers are initialized again. */
+ g_atomic_int_set(&driversInitialized, 1);
}
static void daemonReloadHandler(virNetDaemon *dmn G_GNUC_UNUSED,
{
virThread thr;
- if (!driversInitialized) {
+ if (!g_atomic_int_compare_and_exchange(&driversInitialized, 1, 0)) {
VIR_WARN("Drivers are not initialized, reload ignored");
return;
}
* Not much we can do on error here except log it.
*/
VIR_ERROR(_("Failed to create thread to handle daemon restart"));
+
+ /* Drivers were initialized at the beginning, otherwise we wouldn't
+ * even get here. */
+ g_atomic_int_set(&driversInitialized, 1);
}
}
goto cleanup;
}
- driversInitialized = true;
+ g_atomic_int_set(&driversInitialized, 1);
virNetDaemonSetShutdownCallbacks(dmn,
virStateShutdownPrepare,
cleanup:
virNetlinkEventServiceStopAll();
- if (driversInitialized) {
+ if (g_atomic_int_compare_and_exchange(&driversInitialized, 1, 0)) {
/* NB: Possible issue with timing window between driversInitialized
* setting if virNetlinkEventServerStart fails */
- driversInitialized = false;
virStateCleanup();
}