Check client channel existence
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 17 Dec 2021 06:11:40 +0000 (15:11 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 17 Dec 2021 06:13:27 +0000 (15:13 +0900)
Before creating a new client channel, AMD should check whether it already exists
or not. If it exists, AMD doesn't create the client channel.

Change-Id: Ic147b02a7274371488489b865e0c07b53cfbc07b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/api/amd_api_app_request_broker.cc

index e5301b0..e6bab23 100644 (file)
@@ -311,7 +311,13 @@ extern "C" EXPORT_API int amd_app_request_broker_send(
 
 extern "C" EXPORT_API int amd_app_request_broker_connect(pid_t pid, uid_t uid) {
   auto& broker = AppRequestBroker::GetInst();
-  auto channel = broker.CreateClientChannel(pid, uid);
+  auto channel = broker.FindClientChannel(pid);
+  if (channel != nullptr) {
+    _W("Already exists. pid(%d)", pid);
+    return 0;
+  }
+
+  channel = broker.CreateClientChannel(pid, uid);
   if (channel == nullptr)
     return -ECOMM;