summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--installer/pkgmgr_installer_signal_agent.cc8
-rw-r--r--installer/src/control.cc23
-rw-r--r--installer/src/pkgmgr_installer_debug.h4
3 files changed, 35 insertions, 0 deletions
diff --git a/installer/pkgmgr_installer_signal_agent.cc b/installer/pkgmgr_installer_signal_agent.cc
index 38c5c6b..306e129 100644
--- a/installer/pkgmgr_installer_signal_agent.cc
+++ b/installer/pkgmgr_installer_signal_agent.cc
@@ -330,6 +330,12 @@ static gboolean __handle_signal(gint fd,
free(data);
free(type_name);
+
+ int ret = 0;
+ ssize_t send_byte = send(clifd, &ret, sizeof(ret), MSG_NOSIGNAL);
+ if (send_byte < 0)
+ LOGE("send() is failed. fd: %d, errno: %d", fd, errno);
+
close(clifd);
/* renew timeout */
@@ -386,6 +392,8 @@ int main(int argc, char* argv[]) {
if (r < 0)
return -1;
+ LOGW("signal agent start");
+
g_main_loop_run(loop);
__fini();
diff --git a/installer/src/control.cc b/installer/src/control.cc
index e88213b..db2eb23 100644
--- a/installer/src/control.cc
+++ b/installer/src/control.cc
@@ -17,6 +17,7 @@
#include "control.hh"
+#include <fcntl.h>
#include <getopt.h>
#include <sys/socket.h>
#include <sys/types.h>
@@ -42,6 +43,8 @@ constexpr int OPTVAL_SKIP_CHECK_REFERENCE = 1007;
constexpr int OPTVAL_RECOVER_DB = 1008;
constexpr int OPTVAL_RECOVERY_CLEANUP = 1009;
+constexpr int AGENT_TIMEOUT = 3000;
+
constexpr const char short_opts[] = "k:l:i:d:c:m:t:o:r:p:s:b:e:M:y:u:w:D:A:qGS";
constexpr const struct option long_opts[] = {
{ "session-id", 1, nullptr, 'k' },
@@ -486,6 +489,26 @@ static int __send_signal_to_agent(uid_t uid, void* data, size_t len) {
return -1;
}
+ int flags = fcntl(fd, F_GETFL, 0);
+ if (fcntl(fd, F_SETFL, (flags & (~SOCK_NONBLOCK))) != 0) {
+ _E("Failed to set flags: %d on fd: %d, errno: %d", flags, fd, errno);
+ close(fd);
+ return 0;
+ }
+
+ struct timeval timeout = {
+ .tv_sec = static_cast<time_t>(AGENT_TIMEOUT / 1000),
+ .tv_usec = static_cast<suseconds_t>((AGENT_TIMEOUT % 1000) * 1000)};
+
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
+ _E("setsockopt() is failed. fd: %d, errno: %d", fd, errno);
+
+ int ret;
+ ssize_t recv_byte = recv(fd, &ret, sizeof(ret), 0);
+ if (recv_byte <= 0)
+ _E("recv() is failed. recv_vypte : %d, fd: %d, errno: %d",
+ recv_byte, fd, errno);
+
close(fd);
return 0;
diff --git a/installer/src/pkgmgr_installer_debug.h b/installer/src/pkgmgr_installer_debug.h
index a92a883..dcdc876 100644
--- a/installer/src/pkgmgr_installer_debug.h
+++ b/installer/src/pkgmgr_installer_debug.h
@@ -29,6 +29,10 @@
#define _E LOGE
#endif
+#ifndef _W
+#define _W LOGW
+#endif
+
#ifndef _D
#define _D LOGD
#endif