Modify launchpad_loader_dispose() function 14/298814/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 14 Sep 2023 01:27:04 +0000 (10:27 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 14 Sep 2023 01:27:04 +0000 (10:27 +0900)
The type of the return value is changed to 'int' from 'void'.

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

index fdde825..549314e 100644 (file)
@@ -621,12 +621,14 @@ void Launchpad::HandleDisposeLoaderRequest(std::shared_ptr<Request> request) {
       LoaderManager::GetInst().FindLoaderContextFromPid(caller_pid);
   if (loader_context == nullptr) {
     _E("Failed to find loader context. pid(%d)", caller_pid);
+    request->SendResult(-ENOENT);
     return;
   }
 
   loader_context->Dispose();
   _W("[PAD_CMD_DISPOSE_LOADER] loader_name: %s, pid: %d",
      loader_context->GetLoaderName().c_str(), caller_pid);
+  request->SendResult(0);
 }
 
 void Launchpad::OnIOEventReceived(int fd, int condition) {
index ba5867c..807381d 100644 (file)
@@ -108,9 +108,11 @@ int launchpad_loader_unblock_threads(void);
  *          The launchpad will dispose the loader process using kill().
  * @since_tizen 7.0
  *
+ * @return @c on success,
+ *         otherwise a negative error value
  * @see launchpad_loader_main();
  */
-void launchpad_loader_dispose(void);
+int launchpad_loader_dispose(void);
 
 #ifdef __cplusplus
 }
index 766eb22..bfb301b 100644 (file)
@@ -126,21 +126,6 @@ const tizen_base::Bundle& LaunchpadLoader::GetBundle() const {
   return app_info_.GetBundle();
 }
 
-void LaunchpadLoader::SendDisposalRequest() {
-  int fd = aul_sock_create_launchpad_client(kLaunchpadProcessPoolSock,
-      getuid());
-  if (fd < 0) {
-    _E("Failed to create launchpad client socket. error(%d)", fd);
-    return;
-  }
-
-  tizen_base::Bundle b;
-  int ret = aul_sock_send_bundle_with_fd(fd,
-      static_cast<int>(PadCmd::DisposeLoader), b.GetHandle(), AUL_SOCK_NOREPLY);
-  if (ret != AUL_R_OK)
-    _E("Failed to send disposal request. error(%d)", ret);
-}
-
 void LaunchpadLoader::ResetArgs() {
   memset(argv_[LoaderArg::Type], 0, strlen(argv_[LoaderArg::Type]));
   memset(argv_[LoaderArg::Id], 0, strlen(argv_[LoaderArg::Id]));
@@ -404,12 +389,23 @@ extern "C" EXPORT_API int launchpad_loader_unblock_threads(void) {
   return ThreadControl::GetInst().UnblockThreads();
 }
 
-extern "C" EXPORT_API void launchpad_loader_dispose(void) {
-  if (!::context) {
-    _E("Invalid context");
-    return;
+extern "C" EXPORT_API int launchpad_loader_dispose(void) {
+  int fd =
+      aul_sock_create_launchpad_client(kLaunchpadProcessPoolSock, getuid());
+  if (fd < 0) {
+    _E("Failed to create launchpad client socket. error(%d)", fd);
+    return -ECOMM;
+  }
+
+  tizen_base::Bundle b;
+  int ret =
+      aul_sock_send_bundle_with_fd(fd, static_cast<int>(PadCmd::DisposeLoader),
+                                   b.GetHandle(), AUL_SOCK_NONE);
+  if (ret != AUL_R_OK) {
+    _E("Failed to send disposal request. error(%d)", ret);
+    return ret;
   }
 
-  _W("Dispose");
-  ::context->SendDisposalRequest();
+  _W("Success to send disposal request");
+  return 0;
 }
index c089ab6..8f44252 100644 (file)
@@ -41,7 +41,6 @@ class LaunchpadLoader {
       void* user_data);
   void Quit();
   const tizen_base::Bundle& GetBundle() const;
-  void SendDisposalRequest();
 
  private:
   void WaitForThreads(int threads);