From 62b164b5d2a5fb370f633c884a079f0fbc9a6a4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 4 Mar 2019 13:21:56 +0900 Subject: [PATCH] Use member variable to remain dlopen handle (#4534) Use member variable to avoid warning by handle lost without dlclose() Signed-off-by: Hyeongseok Oh --- libs/ARMComputeEx/arm_compute/core/CL/OpenCLEx.h | 5 +++++ libs/ARMComputeEx/src/core/CL/OpenCLEx.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libs/ARMComputeEx/arm_compute/core/CL/OpenCLEx.h b/libs/ARMComputeEx/arm_compute/core/CL/OpenCLEx.h index dbda354..c0fc615 100644 --- a/libs/ARMComputeEx/arm_compute/core/CL/OpenCLEx.h +++ b/libs/ARMComputeEx/arm_compute/core/CL/OpenCLEx.h @@ -47,6 +47,10 @@ private: void load_symbols(void *handle); public: + /** + * @brief Destroy the CLSymbolsEx object + */ + ~CLSymbolsEx(); /** Get the static instance of CLSymbols. * * @return The static instance of CLSymbols. @@ -74,6 +78,7 @@ public: private: std::pair _loaded{false, false}; + void *_handle{nullptr}; }; } // namespace arm_compute #endif /* __ARM_COMPUTE_OPENCLEX_H__ */ diff --git a/libs/ARMComputeEx/src/core/CL/OpenCLEx.cpp b/libs/ARMComputeEx/src/core/CL/OpenCLEx.cpp index cbda169..24e96e7 100644 --- a/libs/ARMComputeEx/src/core/CL/OpenCLEx.cpp +++ b/libs/ARMComputeEx/src/core/CL/OpenCLEx.cpp @@ -30,6 +30,15 @@ namespace arm_compute { + +CLSymbolsEx::~CLSymbolsEx() +{ + if (_handle != nullptr) + { + dlclose(_handle); + } +} + CLSymbolsEx &CLSymbolsEx::get() { static CLSymbolsEx symbols; @@ -85,6 +94,9 @@ bool CLSymbolsEx::load(const std::string &library) // Disable default loading and set status to successful _loaded = std::make_pair(true, true); + // Workaround to avoid warning by handle lost without dlclose() + _handle = handle; + return true; } -- 2.7.4