summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddie James <eajames@us.ibm.com>2018-06-21 15:57:02 -0500
committerEdward A. James <eajames@us.ibm.com>2018-06-27 18:15:26 +0000
commit4f4712d820ea2e8c49c230be87a60d984ece739a (patch)
tree96507d7e76e7c50f9acb3f6ab6d0ec6da50fd0b7
parent3c1706a8c36f7d05299ca65e2f3dc9a3785566a6 (diff)
downloadopenpower-occ-control-4f4712d820ea2e8c49c230be87a60d984ece739a.zip
openpower-occ-control-4f4712d820ea2e8c49c230be87a60d984ece739a.tar.gz
passthrough: only open /dev/occX during the operation
The file handle was left open constantly, resulting in dead file handles when FSI is rescanned. Change-Id: I1ca8b330131eaad3e3672f5e8fbc3b994e8c34d6 Signed-off-by: Eddie James <eajames@us.ibm.com>
-rw-r--r--occ_pass_through.cpp20
-rw-r--r--occ_pass_through.hpp3
2 files changed, 22 insertions, 1 deletions
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index 4a7057b..424cc22 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -35,6 +35,12 @@ void PassThrough::openDevice()
using namespace phosphor::logging;
using namespace sdbusplus::org::open_power::OCC::Device::Error;
+ if (!occActive)
+ {
+ log<level::INFO>("OCC is inactive; cannot perform pass-through");
+ return;
+ }
+
fd = open(devicePath.c_str(), O_RDWR | O_NONBLOCK);
if (fd < 0)
{
@@ -53,6 +59,7 @@ void PassThrough::closeDevice()
if (fd >= 0)
{
close(fd);
+ fd = -1;
}
}
@@ -63,6 +70,14 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
std::vector<int32_t> response {};
+ openDevice();
+
+ if (fd < 0)
+ {
+ // OCC is inactive; empty response
+ return response;
+ }
+
// OCC only understands [bytes] so need array of bytes. Doing this
// because rest-server currently treats all int* as 32 bit integer.
std::vector<uint8_t> cmdInBytes;
@@ -115,6 +130,8 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
}
}
+ closeDevice();
+
return response;
}
@@ -131,10 +148,11 @@ void PassThrough::activeStatusEvent(sdbusplus::message::message& msg)
// Extract the OccActive property
if (sdbusplus::message::variant_ns::get<bool>(propertyMap->second))
{
- this->openDevice();
+ occActive = true;
}
else
{
+ occActive = false;
this->closeDevice();
}
}
diff --git a/occ_pass_through.hpp b/occ_pass_through.hpp
index 205fc04..384a065 100644
--- a/occ_pass_through.hpp
+++ b/occ_pass_through.hpp
@@ -60,6 +60,9 @@ class PassThrough : public Iface
*/
std::string devicePath;
+ /** @brief Indicates whether or not the OCC is currently active */
+ bool occActive = false;
+
/** brief file descriptor associated with occ device */
int fd = -1;
OpenPOWER on IntegriCloud