summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>2014-08-26 12:16:26 +0400
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>2014-08-26 12:24:53 +0400
commit9dac3264113ccadc1f307308c4c2eaaae6f681b0 (patch)
tree7ab0fb4c661fcc5d48227e0a49323f79e3fc9cd1
parent178fee62215a93f9944ac3a762e2376e62f54b46 (diff)
downloadswap-manager-9dac3264113ccadc1f307308c4c2eaaae6f681b0.tar.gz
swap-manager-9dac3264113ccadc1f307308c4c2eaaae6f681b0.tar.bz2
swap-manager-9dac3264113ccadc1f307308c4c2eaaae6f681b0.zip
[FIX] stop profiling when children terminate
Change-Id: Ie603aa3445fb20c2543f2bbea39eabce618c67d9 Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
-rw-r--r--daemon/daemon.c27
-rw-r--r--daemon/daemon.h9
-rw-r--r--daemon/main.c1
-rw-r--r--daemon/utils.c1
4 files changed, 37 insertions, 1 deletions
diff --git a/daemon/daemon.c b/daemon/daemon.c
index edbb8aa..03d6707 100644
--- a/daemon/daemon.c
+++ b/daemon/daemon.c
@@ -69,6 +69,22 @@
#define MAX_APP_LAUNCH_TIME 60
#define MAX_CONNECT_TIMEOUT_TIME 5*60
+
+int get_comm_pid(void)
+{
+ return manager.comm_pid;
+}
+
+void set_comm_pid(int pid)
+{
+ manager.comm_pid = pid;
+}
+
+void reset_comm_pid(void)
+{
+ set_comm_pid(no_comm_pid);
+}
+
uint64_t get_total_alloc_size_by_pid(pid_t pid)
{
int i;
@@ -310,6 +326,8 @@ void terminate_all()
LOGI("join recv thread %d. done\n", i);
}
}
+
+ reset_comm_pid();
}
// terminate all profiling by critical error
@@ -541,10 +559,16 @@ static int target_event_pid_handler(int index, uint64_t msg)
static int target_event_stop_handler(int index, uint64_t msg)
{
+ int cnt, comm_pid;
+
LOGI("target close, socket(%d), pid(%d) : (remaining %d target)\n",
manager.target[index].socket, manager.target[index].pid,
manager.target_count - 1);
+ comm_pid = get_comm_pid();
+ if (manager.target[index].pid == comm_pid)
+ reset_comm_pid();
+
if (index == 0) // main application
stop_replay();
@@ -552,7 +576,8 @@ static int target_event_stop_handler(int index, uint64_t msg)
setEmptyTargetSlot(index);
// all target client are closed
- if (0 == __sync_sub_and_fetch(&manager.target_count, 1)) {
+ cnt = __sync_sub_and_fetch(&manager.target_count, 1);
+ if (0 == cnt && no_comm_pid == comm_pid) {
LOGI("all targets are stopped\n");
if (stop_all() != ERR_NO)
LOGE("Stop failed\n");
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 8f92e39..251722b 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -164,6 +164,7 @@ typedef struct
typedef struct
{
+ int comm_pid;
int host_server_socket;
int target_server_socket;
int target_count;
@@ -185,6 +186,14 @@ typedef struct
extern __da_manager manager;
+
+enum { no_comm_pid = -1 };
+
+int get_comm_pid(void);
+void set_comm_pid(int pid);
+void reset_comm_pid(void);
+
+
uint64_t get_total_alloc_size(void);
void initialize_log(void);
int daemonLoop(void);
diff --git a/daemon/main.c b/daemon/main.c
index 42d6aec..8474895 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -62,6 +62,7 @@
// initialize global variable
__da_manager manager =
{
+ .comm_pid = no_comm_pid,
.host_server_socket = -1,
.target_server_socket = -1,
.target_count = 0,
diff --git a/daemon/utils.c b/daemon/utils.c
index 4151ffa..12212e3 100644
--- a/daemon/utils.c
+++ b/daemon/utils.c
@@ -185,6 +185,7 @@ int exec_app_common(const char* exec_path)
return -1;
if (pid > 0) { /* parent */
+ set_comm_pid(pid);
return 0;
} else { /* child */
execl(SHELL_CMD, SHELL_CMD, "-c", command, NULL);