summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-10-14 01:19:29 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-14 01:19:29 +0000
commite09bfb1213b9174d4c3d6536b755d924772ce881 (patch)
tree7701f251e74d66a6a4e732b414454ec9037419e8
parentb63aab58065f5fb2a04c5d7c49f1d61bf7e17179 (diff)
parent2c5e7e102bc2059d22f8457db68c567b64cec963 (diff)
downloadsystem_core-e09bfb1213b9174d4c3d6536b755d924772ce881.zip
system_core-e09bfb1213b9174d4c3d6536b755d924772ce881.tar.gz
system_core-e09bfb1213b9174d4c3d6536b755d924772ce881.tar.bz2
am 2c5e7e10: Maybe fix issue #17969789: Shamu FR: Runtime restart while scrolling Instagram
* commit '2c5e7e102bc2059d22f8457db68c567b64cec963': Maybe fix issue #17969789: Shamu FR: Runtime restart while scrolling Instagram
-rw-r--r--libprocessgroup/Android.mk2
-rw-r--r--libprocessgroup/processgroup.cpp32
2 files changed, 29 insertions, 5 deletions
diff --git a/libprocessgroup/Android.mk b/libprocessgroup/Android.mk
index 501321f..051999a 100644
--- a/libprocessgroup/Android.mk
+++ b/libprocessgroup/Android.mk
@@ -3,7 +3,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := processgroup.cpp
LOCAL_MODULE := libprocessgroup
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libutils
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_CFLAGS := -Wall -Werror
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp
index f7bc2cd..d5f3ad3 100644
--- a/libprocessgroup/processgroup.cpp
+++ b/libprocessgroup/processgroup.cpp
@@ -30,6 +30,8 @@
#include <log/log.h>
#include <private/android_filesystem_config.h>
+#include <utils/SystemClock.h>
+
#include <processgroup/processgroup.h>
#include "processgroup_priv.h"
@@ -69,7 +71,7 @@ static int initCtx(uid_t uid, int pid, struct ctx *ctx)
int fd = open(path, O_RDONLY);
if (fd < 0) {
ret = -errno;
- SLOGV("failed to open %s: %s", path, strerror(errno));
+ SLOGW("failed to open %s: %s", path, strerror(errno));
return ret;
}
@@ -78,6 +80,8 @@ static int initCtx(uid_t uid, int pid, struct ctx *ctx)
ctx->buf_len = 0;
ctx->initialized = true;
+ SLOGV("Initialized context for %s", path);
+
return 0;
}
@@ -87,7 +91,7 @@ static int refillBuffer(struct ctx *ctx)
ctx->buf_ptr = ctx->buf;
ssize_t ret = read(ctx->fd, ctx->buf_ptr + ctx->buf_len,
- sizeof(ctx->buf) - ctx->buf_len);
+ sizeof(ctx->buf) - ctx->buf_len - 1);
if (ret < 0) {
return -errno;
} else if (ret == 0) {
@@ -95,6 +99,9 @@ static int refillBuffer(struct ctx *ctx)
}
ctx->buf_len += ret;
+ ctx->buf[ctx->buf_len-1] = 0;
+ SLOGV("Read %d to buffer: %s", ret, ctx->buf);
+
assert(ctx->buf_len <= sizeof(ctx->buf));
return ret;
@@ -131,6 +138,7 @@ static pid_t getOneAppProcess(uid_t uid, int appProcessPid, struct ctx *ctx)
return -EINVAL;
}
+ ctx->buf_len -= (eptr - ctx->buf_ptr) + 1;
ctx->buf_ptr = eptr + 1;
return (pid_t)pid;
@@ -213,10 +221,22 @@ static int killProcessGroupOnce(uid_t uid, int initialPid, int signal)
while ((pid = getOneAppProcess(uid, initialPid, &ctx)) >= 0) {
processes++;
- SLOGV("sending processgroup kill to pid %d\n", pid);
+ if (pid == 0) {
+ // Should never happen... but if it does, trying to kill this
+ // will boomerang right back and kill us! Let's not let that happen.
+ SLOGW("Yikes, we've been told to kill pid 0! How about we don't do that.");
+ continue;
+ }
+ if (pid != initialPid) {
+ // We want to be noisy about killing processes so we can understand
+ // what is going on in the log; however, don't be noisy about the base
+ // process, since that it something we always kill, and we have already
+ // logged elsewhere about killing it.
+ SLOGI("Killing pid %d in uid %d as part of process group %d", pid, uid, initialPid);
+ }
int ret = kill(pid, signal);
if (ret == -1) {
- SLOGV("failed to kill pid %d: %s", pid, strerror(errno));
+ SLOGW("failed to kill pid %d: %s", pid, strerror(errno));
}
}
@@ -231,6 +251,7 @@ int killProcessGroup(uid_t uid, int initialPid, int signal)
{
int processes;
int sleep_us = 100;
+ long startTime = android::uptimeMillis();
while ((processes = killProcessGroupOnce(uid, initialPid, signal)) > 0) {
SLOGV("killed %d processes for processgroup %d\n", processes, initialPid);
@@ -244,6 +265,9 @@ int killProcessGroup(uid_t uid, int initialPid, int signal)
}
}
+ SLOGV("Killed process group uid %d pid %d in %ldms, %d procs remain", uid, initialPid,
+ android::uptimeMillis()-startTime, processes);
+
if (processes == 0) {
return removeProcessGroup(uid, initialPid);
} else {