Check launchpad socket existence 92/317992/1
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 10 Jan 2025 10:31:00 +0000 (19:31 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 10 Jan 2025 10:31:43 +0000 (19:31 +0900)
Before connecting to the socket of the launchpad-process-pool, amd
checks whether it exists or not. When recv() returns an error as like EOF,
amd retries to connect to the socket of the launchpad-process-pool.

Change-Id: Id6d23231d320afa81b929076867d76e76014b866
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/launchpad/launchpad.cc
src/lib/launchpad/launchpad.hh

index 5d30edb09a982d174309c78d83988c088b5b7b76..3a6f5e873c86152cef10917a8b664091d5185015 100644 (file)
@@ -44,6 +44,8 @@ constexpr const char AUL_DBUS_PATH[] = "/aul/dbus_handler";
 constexpr const char AUL_DBUS_SIGNAL_INTERFACE[] = "org.tizen.aul.signal";
 constexpr const char AUL_DBUS_APPDEAD_SIGNAL[] = "app_dead";
 constexpr const char AUL_DBUS_APPLAUNCH_SIGNAL[] = "app_launch";
+constexpr const char kLaunchpadProcessPoolSock[] =
+    ".launchpad-process-pool-sock";
 
 class GarbageCollector : public Worker::Job {
  public:
@@ -271,6 +273,12 @@ int Launchpad::SendAndReceive(int cmd, bundle* request, uid_t uid) {
 }
 
 bool Launchpad::ListenSigchld() {
+  std::string path = GetEndpoint(uid_, kLaunchpadProcessPoolSock);
+  if (access(path.c_str(), F_OK) != 0) {
+    _W("%s doesn't exist", path.c_str());
+    return false;
+  }
+
   try {
     sigchld_socket_.reset(new ClientSocket());
     std::string endpoint = GetEndpoint(uid_, LAUNCHPAD_PROCESS_POOL_SOCK);
@@ -363,20 +371,20 @@ void Launchpad::OnResultReceived(int fd, int result) {
   channels_.erase(found);
 }
 
-void Launchpad::HandleSigchldEvent() {
+bool Launchpad::HandleSigchldEvent() {
   size_t data_size = 0;
   int ret = sigchld_socket_->Receive(static_cast<void*>(&data_size),
                                      sizeof(data_size));
   if (ret != 0) {
     _E("Receive() is failed. error=%d", ret);
-    return;
+    return false;
   }
 
   std::vector<uint8_t> data(data_size);
   ret = sigchld_socket_->Receive(data.data(), data_size);
   if (ret != 0) {
     _E("Receive() is failed. error=%d", ret);
-    return;
+    return false;
   }
 
   tizen_base::Parcel parcel(data.data(), data.size());
@@ -394,12 +402,17 @@ void Launchpad::HandleSigchldEvent() {
   }
 
   if (listener_) listener_->OnSigchldEvent(pid, status);
+
+  return true;
 }
 
 gboolean Launchpad::UnixFdFunc(gint fd, GIOCondition cond, gpointer user_data) {
   _D("fd=%d, cond=%d", fd, static_cast<int>(cond));
   auto* self = static_cast<Launchpad*>(user_data);
-  self->HandleSigchldEvent();
+  if (!self->HandleSigchldEvent()) {
+    self->IgnoreSigchld();
+    self->retry_source_ = g_timeout_add(100, RetryFunc, self);
+  }
   return G_SOURCE_CONTINUE;
 }
 
index 4bd8d4de1e73e63b317a339ce1d35a496365019c..262608ddbbdda35df41d7fbeed6de92fefc0ed82 100644 (file)
@@ -63,7 +63,7 @@ class Launchpad : public ClientChannel::IEvent {
   void SendAppLaunchSignal(pid_t pid, const std::string& appid);
   void SendAppDeadSignal(pid_t pid, int status);
   void OnResultReceived(int fd, int result) override;
-  void HandleSigchldEvent();
+  bool HandleSigchldEvent();
   bool ListenSigchld();
   static gboolean UnixFdFunc(gint fd, GIOCondition cond, gpointer user_data);
   static gboolean RetryFunc(gpointer user_data);