diff options
author | Andrew Geissler <andrewg@us.ibm.com> | 2017-04-03 13:31:13 -0500 |
---|---|---|
committer | Andrew Geissler <andrewg@us.ibm.com> | 2017-05-09 12:51:59 -0500 |
commit | 8315970370d63b101bd0bd579bc1f697a3c8d07c (patch) | |
tree | 856438abae898d4edd29a6df9e6ccf5e1c28aa20 /host-interface.hpp | |
parent | 857f54b71198dcb5a1d5acae98f0c0cb78298694 (diff) | |
download | phosphor-host-ipmid-8315970370d63b101bd0bd579bc1f697a3c8d07c.tar.gz phosphor-host-ipmid-8315970370d63b101bd0bd579bc1f697a3c8d07c.zip |
Add timeout support to host control
On timeout, send error signal for all commands within the queue
Change-Id: Ic995fd4b057bd83f121a3deec405a26e0991e9a2
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'host-interface.hpp')
-rw-r--r-- | host-interface.hpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/host-interface.hpp b/host-interface.hpp index 0ad3bfb..8901a2b 100644 --- a/host-interface.hpp +++ b/host-interface.hpp @@ -4,7 +4,7 @@ #include <sdbusplus/bus.hpp> #include <phosphor-logging/elog.hpp> #include <xyz/openbmc_project/Control/Host/server.hpp> -#include "elog-errors.hpp" +#include <timer.hpp> namespace phosphor { @@ -26,13 +26,17 @@ class Host : public sdbusplus::server::object::object< * * @param[in] bus - The Dbus bus object * @param[in] objPath - The Dbus object path + * @param[in] events - The sd_event pointer */ Host(sdbusplus::bus::bus& bus, - const char* objPath) : + const char* objPath, + sd_event* events) : sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Control::server::Host>( bus, objPath), - bus(bus) + bus(bus), + timer(events, + std::bind(&Host::hostTimeout, this)) {} /** @brief Send input command to host @@ -51,30 +55,24 @@ class Host : public sdbusplus::server::object::object< * passed to the host (which is required when calling this interface) * */ - Command getNextCommand() - { - if(this->workQueue.empty()) - { - log<level::ERR>("Control Host work queue is empty!"); - elog<xyz::openbmc_project::Control::Internal::Host::QueueEmpty>(); - } - Command command = this->workQueue.front(); - this->workQueue.pop(); - this->commandComplete(command, Result::Success); - this->checkQueue(); - return command; - } + Command getNextCommand(); private: /** @brief Check if anything in queue and alert host if so */ void checkQueue(); + /** @brief Call back interface on message timeouts to host */ + void hostTimeout(); + /** @brief Persistent sdbusplus DBus bus connection. */ sdbusplus::bus::bus& bus; /** @brief Queue to store the requested commands */ std::queue<Command> workQueue{}; + + /** @brief Timer for commands to host */ + phosphor::ipmi::Timer timer; }; } // namespace host |