From: kibak.yoon Date: Thu, 31 Mar 2016 01:41:24 +0000 (+0900) Subject: sensord: close handles in sensor_loader destructor X-Git-Tag: accepted/tizen/common/20160406.143452~1^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F64507%2F1;p=platform%2Fcore%2Fsystem%2Fsensord.git sensord: close handles in sensor_loader destructor Change-Id: Ie24606b850a13708956808b36210a86983d62ae3 Signed-off-by: kibak.yoon --- diff --git a/src/server/sensor_loader.cpp b/src/server/sensor_loader.cpp index 785fab2..d525d98 100644 --- a/src/server/sensor_loader.cpp +++ b/src/server/sensor_loader.cpp @@ -50,6 +50,14 @@ sensor_loader::sensor_loader() { } +sensor_loader::~sensor_loader() +{ + for (auto it = m_handles.begin(); it != m_handles.end(); ++it) + dlclose(*it); + + m_handles.clear(); +} + sensor_loader& sensor_loader::get_instance() { static sensor_loader inst; @@ -79,6 +87,7 @@ bool sensor_loader::load(void) [&](const string &path) { void *handle; load_sensor_devices(path, handle); + m_handles.push_back(handle); } ); diff --git a/src/server/sensor_loader.h b/src/server/sensor_loader.h index 763ea9a..b303301 100644 --- a/src/server/sensor_loader.h +++ b/src/server/sensor_loader.h @@ -41,6 +41,7 @@ typedef std::map sensor_device_map_t; class sensor_loader { private: sensor_loader(); + virtual ~sensor_loader(); bool load_sensor_devices(const std::string &path, void* &handle); @@ -54,6 +55,7 @@ private: sensor_map_t m_sensors; sensor_device_map_t m_devices; + std::vector m_handles; public: static sensor_loader& get_instance(); bool load(void);