]> xenbits.xensource.com Git - people/pauldu/xeniface.git/commitdiff
Revert "Ack "control/shutdown" as soon as possible."
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 10 Apr 2018 15:10:02 +0000 (16:10 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 10 Apr 2018 15:10:02 +0000 (16:10 +0100)
This reverts commit c370c7d2. This patch has the effect of 'acking' any
write to control/shutdown rather than just the ones that the agent acts
upon. Consequentially it therefore 'acks' its own writes and ends up in
an infinite loop.

src/xenagent/service.cpp

index 96e620a88b1754b743110fe50029c12b8b93ff29..46250e8ce0a9a06ba31f178ac2c54bcdc6ff0131 100644 (file)
@@ -187,13 +187,12 @@ 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,
@@ -206,6 +205,7 @@ 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,6 +218,7 @@ 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());
@@ -226,6 +227,7 @@ 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());