From 6feb22c03265e868767827fc6d444769612b202a Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Wed, 12 Feb 2025 12:12:00 +0900 Subject: [PATCH] shared: Fix to release channel resources when sensor_listener is released 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 --- src/client/sensor_listener.cpp | 2 ++ src/shared/event_loop.cpp | 5 +++++ src/shared/event_loop.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/client/sensor_listener.cpp b/src/client/sensor_listener.cpp index 649a4d4f..dcba6741 100644 --- a/src/client/sensor_listener.cpp +++ b/src/client/sensor_listener.cpp @@ -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.."); diff --git a/src/shared/event_loop.cpp b/src/shared/event_loop.cpp index 720687b8..639af657 100644 --- a/src/shared/event_loop.cpp +++ b/src/shared/event_loop.cpp @@ -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); diff --git a/src/shared/event_loop.h b/src/shared/event_loop.h index aeae959c..83357515 100644 --- a/src/shared/event_loop.h +++ b/src/shared/event_loop.h @@ -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); -- 2.34.1