Commit a3a1aed7 authored by topjohnwu's avatar topjohnwu

Don't check zygote in busy loop

parent 81aa56f6
...@@ -123,10 +123,6 @@ void update_uid_map() { ...@@ -123,10 +123,6 @@ void update_uid_map() {
} }
static void check_zygote() { static void check_zygote() {
int min_zyg = 1;
if (access("/system/bin/app_process64", R_OK) == 0)
min_zyg = 2;
for (;;) {
crawl_procfs([](int pid) -> bool { crawl_procfs([](int pid) -> bool {
char buf[512]; char buf[512];
snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid); snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
...@@ -138,10 +134,6 @@ static void check_zygote() { ...@@ -138,10 +134,6 @@ static void check_zygote() {
} }
return true; return true;
}); });
if (zygote_map.size() >= min_zyg)
break;
usleep(10000);
}
} }
#define APP_PROC "/system/bin/app_process" #define APP_PROC "/system/bin/app_process"
...@@ -189,14 +181,9 @@ static void inotify_event(int) { ...@@ -189,14 +181,9 @@ static void inotify_event(int) {
char buf[512]; char buf[512];
auto event = reinterpret_cast<struct inotify_event *>(buf); auto event = reinterpret_cast<struct inotify_event *>(buf);
read(inotify_fd, buf, sizeof(buf)); read(inotify_fd, buf, sizeof(buf));
if ((event->mask & IN_CLOSE_WRITE) && strcmp(event->name, "packages.xml") == 0) { if ((event->mask & IN_CLOSE_WRITE) && event->name == "packages.xml"sv)
LOGD("proc_monitor: /data/system/packages.xml updated\n"); update_uid_map();
uid_proc_map.clear();
file_readline("/data/system/packages.xml", parse_packages_xml, true);
} else if (event->mask & IN_ACCESS) {
LOGD("proc_monitor: app_process access\n");
check_zygote(); check_zygote();
}
} }
// Workaround for the lack of pthread_cancel // Workaround for the lack of pthread_cancel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment