Fix retrieving app com connections 61/260261/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 22 Jun 2021 23:54:02 +0000 (08:54 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 22 Jun 2021 23:57:03 +0000 (08:57 +0900)
To allow delete this, app com uses std::iterator. After this patch is
applied, the caller process can call aul_app_com_leave() while calling
the app_com_cb() callback function.

Change-Id: I0e6202810d99af556197c35b9c06303185e25482
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/app_com.cc

index ac1d988..e992b88 100644 (file)
@@ -101,7 +101,10 @@ class Context {
     std::string endpoint(val);
 
     std::lock_guard<std::recursive_mutex> lock(mutex_);
-    for (auto& conn : conns_) {
+    auto iter = conns_.begin();
+    while (iter != conns_.end()) {
+      auto& conn = *iter;
+      iter++;
       if (conn->GetEndpoint() == endpoint)
         conn->Invoke(*result, b);
     }