summaryrefslogtreecommitdiffstats
path: root/softoff/mainapp.cpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-02-24 00:16:05 +0530
committerAndrew Geissler <geissonator@yahoo.com>2017-03-29 13:29:18 +0000
commit917454bb139be75f656ddfa451e5036fc24ce640 (patch)
treee8e55b7539804d070257e8425df777a29e994783 /softoff/mainapp.cpp
parent0661beb1dd93711ce684450997d21da8b64c729d (diff)
downloadphosphor-host-ipmid-917454bb139be75f656ddfa451e5036fc24ce640.tar.gz
phosphor-host-ipmid-917454bb139be75f656ddfa451e5036fc24ce640.zip
Generate errorlog when timer expires waiting for host to shutdown
Fixes openbmc/openbmc#930 Change-Id: I1780071d5cbef23df88c17fe131098f54f54f25f Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'softoff/mainapp.cpp')
-rw-r--r--softoff/mainapp.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/softoff/mainapp.cpp b/softoff/mainapp.cpp
index 9ed34dd..1f037fc 100644
--- a/softoff/mainapp.cpp
+++ b/softoff/mainapp.cpp
@@ -14,7 +14,9 @@
* limitations under the License.
*/
#include <systemd/sd-event.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/State/Host/error.hpp>
#include "softoff.hpp"
#include "config.h"
#include "timer.hpp"
@@ -45,14 +47,14 @@ int main(int argc, char** argv)
// Attach the bus to sd_event to service user requests
bus.attach_event(events, SD_EVENT_PRIORITY_NORMAL);
- // Create the SoftPowerOff object.
- phosphor::ipmi::SoftPowerOff powerObj(bus, events, SOFTOFF_OBJPATH);
-
// Claim the bus. Delaying it until sending SMS_ATN may result
// in a race condition between this available and IPMI trying to send
// message as a reponse to ack from host.
bus.request_name(SOFTOFF_BUSNAME);
+ // Create the SoftPowerOff object.
+ phosphor::ipmi::SoftPowerOff powerObj(bus, events, SOFTOFF_OBJPATH);
+
// Wait for client requests until this application has processed
// at least one successful SoftPowerOff or we timed out
while(!powerObj.isCompleted() && !powerObj.isTimerExpired())
@@ -67,6 +69,25 @@ int main(int argc, char** argv)
}
}
+ // Log an error if we timed out after getting Ack for SMS_ATN and before
+ // getting the Host Shutdown response
+ if(powerObj.isTimerExpired() && (powerObj.responseReceived() ==
+ phosphor::ipmi::Base::SoftPowerOff::HostResponse::SoftOffReceived))
+ {
+ try
+ {
+ elog<sdbusplus::xyz::openbmc_project::State
+ ::Host::Error::SoftOffTimeout>(
+ prev_entry<phosphor::logging::xyz::openbmc_project::State
+ ::Host::SoftOffTimeout::TIMEOUT_IN_MSEC>());
+ }
+ catch (sdbusplus::xyz::openbmc_project::State::Host::Error
+ ::SoftOffTimeout& elog)
+ {
+ commit(elog.name());
+ }
+ }
+
// Cleanup the event handler
events = sd_event_unref(events);
OpenPOWER on IntegriCloud