From 6b1a5c83bdb6c4d0619d7c154a223f6a1d97d52d Mon Sep 17 00:00:00 2001 From: Matt Spinler Date: Tue, 7 Jan 2020 08:48:53 -0600 Subject: 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 Change-Id: I2b850a1c92215e7f66166cc5440d7071663065c0 --- extensions/openpower-pels/manager.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'extensions/openpower-pels/manager.hpp') 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 #include +#include +#include namespace openpower { @@ -175,6 +177,27 @@ class Manager : public PELInterface const std::vector& additionalData, const std::vector& 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 */ @@ -200,6 +223,12 @@ class Manager : public PELInterface * host about new PELs */ std::unique_ptr _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 _fdCloserEventSource; }; } // namespace pels -- cgit v1.2.1