Modify loader handling 79/315479/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 1 Aug 2024 10:10:39 +0000 (19:10 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 1 Aug 2024 10:39:27 +0000 (19:39 +0900)
- Calls exit() when getting the I/O error from the socket fd
- Checks whether the disconnected loader process is equal to the current process

Change-Id: I1a1690a0ef188b21ea7a4276d17247d593d57950
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/loader_context.cc
src/lib/launchpad/launchpad_loader.cc

index 513dc78b3659078441cf97546df3de67c5384c28..de99fa16bf107f8dd7fd56e730c15db9d5c163ab 100644 (file)
@@ -670,10 +670,16 @@ void LoaderContext::HandleLoaderEvent() {
 void LoaderContext::HandleLoaderClientEvent(int condition) {
   if (condition &
       (IOChannel::IOCondition::IO_HUP | IOChannel::IOCondition::IO_NVAL)) {
-    SECURE_LOGE("Type %d loader was disconnected. pid: %d", GetType(), pid_);
-    SetPid(0);
-    Dispose();
-    Prepare();
+    auto peer_cred = PeerCredentials::Get(client_socket_->GetFd());
+    if (!peer_cred) return;
+
+    if (peer_cred->GetPid() == pid_) {
+      SECURE_LOGE("Type %d loader was disconnected. pid: %d", GetType(), pid_);
+      Dispose();
+      Prepare();
+    } else {
+      SECURE_LOGE("pid(%d) was disconnected", peer_cred->GetPid());
+    }
   }
 }
 
index 2f3faa132eebd4ee6b1fdd5303dcb72f1bd37c33..da5048f632e7b3affd525fc2ff269f9399b3e75c 100644 (file)
@@ -294,14 +294,14 @@ void LaunchpadLoader::HandleReceiverEvent(int fd) {
   int ret = socket.Receive(static_cast<void*>(&data_size), sizeof(data_size));
   if (ret != 0) {
     _E("Failed to receive the data from socket. error(%d)", ret);
-    return;
+    exit(-1);
   }
 
   std::vector<uint8_t> data(data_size);
   ret = socket.Receive(data.data(), data.size());
   if (ret != 0) {
     _E("Failed to receive the data from socket. error(%d)", ret);
-    return;
+    exit(-1);
   }
 
   tizen_base::Parcel parcel(data.data(), data.size());