From c370c7d2859e9b2bc3c69beb78b2f1554c3e5142 Mon Sep 17 00:00:00 2001 From: Owen Smith Date: Thu, 22 Mar 2018 11:20:05 +0000 Subject: [PATCH] Ack "control/shutdown" as soon as possible. Signed-off-by: Owen Smith --- src/xenagent/service.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/xenagent/service.cpp b/src/xenagent/service.cpp index 46250e8..96e620a 100644 --- a/src/xenagent/service.cpp +++ b/src/xenagent/service.cpp @@ -187,12 +187,13 @@ bool CXenIfaceCreator::CheckShutdown() if (!m_device->StoreRead("control/shutdown", type)) return false; + m_device->StoreWrite("control/shutdown", ""); + CXenAgent::Log("Shutdown(%ws) = %s\n", m_device->Path(), type.c_str()); if (type == "poweroff") { m_agent.EventLog(EVENT_XENUSER_POWEROFF); - m_device->StoreWrite("control/shutdown", ""); AcquireShutdownPrivilege(); #pragma warning(suppress:28159) /* Consider using a design alternative... Rearchitect to avoid Reboot */ if (!InitiateSystemShutdownEx(NULL, NULL, 0, TRUE, FALSE, @@ -205,7 +206,6 @@ bool CXenIfaceCreator::CheckShutdown() } else if (type == "reboot") { m_agent.EventLog(EVENT_XENUSER_REBOOT); - m_device->StoreWrite("control/shutdown", ""); AcquireShutdownPrivilege(); #pragma warning(suppress:28159) /* Consider using a design alternative... Rearchitect to avoid Reboot */ if (!InitiateSystemShutdownEx(NULL, NULL, 0, TRUE, TRUE, @@ -218,7 +218,6 @@ bool CXenIfaceCreator::CheckShutdown() } else if (type == "s4") { m_agent.EventLog(EVENT_XENUSER_S4); - m_device->StoreWrite("control/shutdown", ""); AcquireShutdownPrivilege(); if (!SetSystemPowerState(FALSE, FALSE)) { CXenAgent::Log("SetSystemPowerState failed %08x\n", GetLastError()); @@ -227,7 +226,6 @@ bool CXenIfaceCreator::CheckShutdown() } else if (type == "s3") { m_agent.EventLog(EVENT_XENUSER_S3); - m_device->StoreWrite("control/shutdown", ""); AcquireShutdownPrivilege(); if (!SetSuspendState(FALSE, TRUE, FALSE)) { CXenAgent::Log("SetSuspendState failed %08x\n", GetLastError()); -- 2.39.5