]> xenbits.xensource.com Git - pvdrivers/win/xeniface.git/commitdiff
Ack actionable "control/shutdown" requests as soon as possible
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 10 Apr 2018 16:17:03 +0000 (17:17 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 10 Apr 2018 16:17:03 +0000 (17:17 +0100)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xenagent/service.cpp

index 46250e8ce0a9a06ba31f178ac2c54bcdc6ff0131..6b042c446d9d4a8ca073fa252a5fe203838b8862 100644 (file)
@@ -187,12 +187,13 @@ bool CXenIfaceCreator::CheckShutdown()
     if (!m_device->StoreRead("control/shutdown", type))
         return false;
 
-    CXenAgent::Log("Shutdown(%ws) = %s\n", m_device->Path(), type.c_str());
+    if (type != "")
+        CXenAgent::Log("Shutdown(%ws) = '%s'\n", m_device->Path(), type.c_str());
 
     if (type == "poweroff") {
+        m_device->StoreWrite("control/shutdown", "");
         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,
@@ -203,9 +204,9 @@ bool CXenIfaceCreator::CheckShutdown()
         }
         return true;
     } else if (type == "reboot") {
+        m_device->StoreWrite("control/shutdown", "");
         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,
@@ -216,18 +217,18 @@ bool CXenIfaceCreator::CheckShutdown()
         }
         return true;
     } else if (type == "s4") {
+        m_device->StoreWrite("control/shutdown", "");
         m_agent.EventLog(EVENT_XENUSER_S4);
 
-        m_device->StoreWrite("control/shutdown", "");
         AcquireShutdownPrivilege();
         if (!SetSystemPowerState(FALSE, FALSE)) {
             CXenAgent::Log("SetSystemPowerState failed %08x\n", GetLastError());
         }
         return true;
     } else if (type == "s3") {
+        m_device->StoreWrite("control/shutdown", "");
         m_agent.EventLog(EVENT_XENUSER_S3);
 
-        m_device->StoreWrite("control/shutdown", "");
         AcquireShutdownPrivilege();
         if (!SetSuspendState(FALSE, TRUE, FALSE)) {
             CXenAgent::Log("SetSuspendState failed %08x\n", GetLastError());