Fix memory leak 94/275994/2
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 8 Jun 2022 07:33:22 +0000 (16:33 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 8 Jun 2022 07:36:23 +0000 (16:36 +0900)
When the handle is destroying, the session information of the DebugPort
has to be removed.

Change-Id: I6c931b889261d4d5374ac89775c2b50a1c6ad483
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/proxy-internal.cc
src/stub-internal.cc

index faaa062..2eb538b 100644 (file)
@@ -105,6 +105,9 @@ Proxy::Proxy() {
 Proxy::~Proxy() {
   std::lock_guard<std::recursive_mutex> lock(GetMutex());
   _D("Proxy::~Proxy()");
+  if (main_port_.get() != nullptr)
+    DebugPort::GetInst()->RemoveSession(main_port_->GetFd());
+
   listener_ = nullptr;
   UnsetIdler();
   UnsetConnTimer();
index f16035c..1ffc2e8 100644 (file)
@@ -95,6 +95,11 @@ Stub::Stub(std::string port_name) : port_name_(std::move(port_name)) {
 Stub::~Stub() {
   std::lock_guard<std::recursive_mutex> lock(GetMutex());
   _D("Stub::~Stub");
+  for (auto& p : ports_) {
+    if (!p->IsDelegate())
+      DebugPort::GetInst()->RemoveSession(p->GetFd());
+  }
+
   listener_ = nullptr;
   server_.reset();
 }