diff options
author | Matt Spinler <spinler@us.ibm.com> | 2020-01-07 08:48:53 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2020-01-27 08:25:12 -0600 |
commit | 6b1a5c83bdb6c4d0619d7c154a223f6a1d97d52d (patch) | |
tree | a47db58f42a40d3aeead1f7b53212f0dd5a50a08 /extensions/openpower-pels/manager.hpp | |
parent | a34ab72c40382f98ff0d1badf909013ab3a458f5 (diff) | |
download | phosphor-logging-6b1a5c83bdb6c4d0619d7c154a223f6a1d97d52d.tar.gz phosphor-logging-6b1a5c83bdb6c4d0619d7c154a223f6a1d97d52d.zip |
PEL: Close PEL FD after getPEL call
To close the file descriptor returned from the getPEL D-Bus method call,
use the 'Defer' sdeventplus object to schedule it to happen from the
event loop.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2b850a1c92215e7f66166cc5440d7071663065c0
Diffstat (limited to 'extensions/openpower-pels/manager.hpp')
-rw-r--r-- | extensions/openpower-pels/manager.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp index 7f1fcda..14904a9 100644 --- a/extensions/openpower-pels/manager.hpp +++ b/extensions/openpower-pels/manager.hpp @@ -11,6 +11,8 @@ #include <org/open_power/Logging/PEL/server.hpp> #include <sdbusplus/server.hpp> +#include <sdeventplus/event.hpp> +#include <sdeventplus/source/event.hpp> namespace openpower { @@ -176,6 +178,27 @@ class Manager : public PELInterface const std::vector<std::string>& associations); /** + * @brief Schedules a close of the file descriptor to occur from + * the event loop. + * + * Uses sd_event_add_defer + * + * @param[in] fd - The file descriptor to close + */ + void scheduleFDClose(int fd); + + /** + * @brief Closes the file descriptor passed in. + * + * This is called from the event loop to close FDs returned + * from getPEL(). + * + * @param[in] fd - The file descriptor to close + * @param[in] source - The event source object used + */ + void closeFD(int fd, sdeventplus::source::EventBase& source); + + /** * @brief Reference to phosphor-logging's Manager class */ phosphor::logging::internal::Manager& _logManager; @@ -200,6 +223,12 @@ class Manager : public PELInterface * host about new PELs */ std::unique_ptr<HostNotifier> _hostNotifier; + + /** + * @brief The event source for closing a PEL file descriptor after + * it has been returned from the getPEL D-Bus method. + */ + std::unique_ptr<sdeventplus::source::Defer> _fdCloserEventSource; }; } // namespace pels |