shared: Fix to release channel resources when sensor_listener is released 19/319519/1 accepted/tizen_7.0_unified tizen_7.0 accepted/tizen/7.0/unified/20250214.180514
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 12 Feb 2025 03:12:00 +0000 (12:12 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Wed, 12 Feb 2025 07:58:34 +0000 (16:58 +0900)
In the event loop object, channel resources(class 'channel' and
'channel_handler') to be released are added to the queues through
functions: add_channel_release_queue, add_channel_handler_release_list
respectively.

Resources contained by these queues should be freed by function
g_io_handler but this function is called when channel receives a
event(GLib.IOCondition) and if no event is occured, resources are not
released. This may cause resources like socket fd, memory flooded, so
they should be released

To resolve this issue, a function is added to the event_loop class to
release resources contained by the queues and that function is called by
the sensor_listener when it is released.

Change-Id: I7eb1be520a6dd756a6cd2718ce15ec813973ecb0
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/client/sensor_listener.cpp
src/shared/event_loop.cpp
src/shared/event_loop.h

index 649a4d4f5a39f171418d946ee7f9eb607614e03a..dcba674176f6167c1768ffcb096cb66bcec3d4b6 100644 (file)
@@ -182,6 +182,8 @@ void sensor_listener::deinit(void)
        m_attributes_int.clear();
        m_attributes_str.clear();
 
+       m_loop->release_unused_channel_resources();
+
        m_initialized = false;
 
        _D("Deinitialized..");
index 720687b8c38ab8ab2bb0ee66fe6fb7c5e6d131f6..639af657da2cf627c8411bc7bd3a577ca2ee9b80 100644 (file)
@@ -266,6 +266,11 @@ void event_loop::release_info(handler_info *info)
        /* _D("Released event[%llu]", info->id); */
 }
 
+void event_loop::release_unused_channel_resources(void)
+{
+       release_res();
+}
+
 void event_loop::add_channel_release_queue(channel *ch)
 {
        AUTOLOCK(release_lock);
index aeae959c36f1ea89d358504155be8728fe0decd0..833575153a406f428f3c3d580aeebbe41916266c 100644 (file)
@@ -84,6 +84,7 @@ public:
        bool remove_event(uint64_t id);
        void remove_all_events(void);
        void release_info(handler_info *info);
+       void release_unused_channel_resources(void);
 
        void add_channel_release_queue(channel *ch);
        void add_channel_handler_release_list(channel_handler *handler);