summaryrefslogtreecommitdiffstats
path: root/adb
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-09-29 18:34:17 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-09-29 18:34:17 +0000
commitbc3d3625d5646ecb7de9291bdaba36b1fed1e2ef (patch)
tree9c8aa57a7a3b7c8290e400d84cf0458c7dc19cd5 /adb
parentb08be62fcadc59df8005f509cec7188fad92f1b2 (diff)
parent39071a517738b24611ae373c9a608a4ca00d0630 (diff)
downloadsystem_core-bc3d3625d5646ecb7de9291bdaba36b1fed1e2ef.tar.gz
system_core-bc3d3625d5646ecb7de9291bdaba36b1fed1e2ef.tar.bz2
system_core-bc3d3625d5646ecb7de9291bdaba36b1fed1e2ef.zip
Merge "adbd: improve thread names."
am: 39071a5177 Change-Id: Id41804332dfb81a2bcfd07d3a7180f16e7412bc0
Diffstat (limited to 'adb')
-rw-r--r--adb/services.cpp39
-rw-r--r--adb/shell_service.cpp3
2 files changed, 22 insertions, 20 deletions
diff --git a/adb/services.cpp b/adb/services.cpp
index ca345568d..aff7012ee 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -58,6 +58,7 @@
#include "transport.h"
struct stinfo {
+ const char* service_name;
void (*func)(int fd, void *cookie);
int fd;
void *cookie;
@@ -65,7 +66,7 @@ struct stinfo {
static void service_bootstrap_func(void* x) {
stinfo* sti = reinterpret_cast<stinfo*>(x);
- adb_thread_setname(android::base::StringPrintf("service %d", sti->fd));
+ adb_thread_setname(android::base::StringPrintf("%s svc %d", sti->service_name, sti->fd));
sti->func(sti->fd, sti->cookie);
free(sti);
}
@@ -160,8 +161,7 @@ static bool reboot_service_impl(int fd, const char* arg) {
return true;
}
-void reboot_service(int fd, void* arg)
-{
+void reboot_service(int fd, void* arg) {
if (reboot_service_impl(fd, static_cast<const char*>(arg))) {
// Don't return early. Give the reboot command time to take effect
// to avoid messing up scripts which do "adb reboot && adb wait-for-device"
@@ -236,8 +236,7 @@ static int ShellService(const std::string& args, const atransport* transport) {
#endif // !ADB_HOST
-static int create_service_thread(void (*func)(int, void *), void *cookie)
-{
+static int create_service_thread(const char* service_name, void (*func)(int, void*), void* cookie) {
int s[2];
if (adb_socketpair(s)) {
printf("cannot create service socket pair\n");
@@ -258,6 +257,7 @@ static int create_service_thread(void (*func)(int, void *), void *cookie)
if (sti == nullptr) {
fatal("cannot allocate stinfo");
}
+ sti->service_name = service_name;
sti->func = func;
sti->cookie = cookie;
sti->fd = s[1];
@@ -281,7 +281,7 @@ int service_to_fd(const char* name, const atransport* transport) {
} else if(!strncmp("dev:", name, 4)) {
ret = unix_open(name + 4, O_RDWR | O_CLOEXEC);
} else if(!strncmp(name, "framebuffer:", 12)) {
- ret = create_service_thread(framebuffer_service, 0);
+ ret = create_service_thread("fb", framebuffer_service, nullptr);
} else if (!strncmp(name, "jdwp:", 5)) {
ret = create_jdwp_connection_fd(atoi(name+5));
} else if(!strncmp(name, "shell", 5)) {
@@ -289,17 +289,17 @@ int service_to_fd(const char* name, const atransport* transport) {
} else if(!strncmp(name, "exec:", 5)) {
ret = StartSubprocess(name + 5, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
} else if(!strncmp(name, "sync:", 5)) {
- ret = create_service_thread(file_sync_service, NULL);
+ ret = create_service_thread("sync", file_sync_service, nullptr);
} else if(!strncmp(name, "remount:", 8)) {
- ret = create_service_thread(remount_service, NULL);
+ ret = create_service_thread("remount", remount_service, nullptr);
} else if(!strncmp(name, "reboot:", 7)) {
void* arg = strdup(name + 7);
if (arg == NULL) return -1;
- ret = create_service_thread(reboot_service, arg);
+ ret = create_service_thread("reboot", reboot_service, arg);
} else if(!strncmp(name, "root:", 5)) {
- ret = create_service_thread(restart_root_service, NULL);
+ ret = create_service_thread("root", restart_root_service, nullptr);
} else if(!strncmp(name, "unroot:", 7)) {
- ret = create_service_thread(restart_unroot_service, NULL);
+ ret = create_service_thread("unroot", restart_unroot_service, nullptr);
} else if(!strncmp(name, "backup:", 7)) {
ret = StartSubprocess(android::base::StringPrintf("/system/bin/bu backup %s",
(name + 7)).c_str(),
@@ -312,17 +312,20 @@ int service_to_fd(const char* name, const atransport* transport) {
if (sscanf(name + 6, "%d", &port) != 1) {
return -1;
}
- ret = create_service_thread(restart_tcp_service, (void *) (uintptr_t) port);
+ ret = create_service_thread("tcp", restart_tcp_service, reinterpret_cast<void*>(port));
} else if(!strncmp(name, "usb:", 4)) {
- ret = create_service_thread(restart_usb_service, NULL);
+ ret = create_service_thread("usb", restart_usb_service, nullptr);
} else if (!strncmp(name, "reverse:", 8)) {
ret = reverse_service(name + 8);
} else if(!strncmp(name, "disable-verity:", 15)) {
- ret = create_service_thread(set_verity_enabled_state_service, (void*)0);
+ ret = create_service_thread("verity-on", set_verity_enabled_state_service,
+ reinterpret_cast<void*>(0));
} else if(!strncmp(name, "enable-verity:", 15)) {
- ret = create_service_thread(set_verity_enabled_state_service, (void*)1);
+ ret = create_service_thread("verity-off", set_verity_enabled_state_service,
+ reinterpret_cast<void*>(1));
} else if (!strcmp(name, "reconnect")) {
- ret = create_service_thread(reconnect_service, const_cast<atransport*>(transport));
+ ret = create_service_thread("reconnect", reconnect_service,
+ const_cast<atransport*>(transport));
#endif
}
if (ret >= 0) {
@@ -484,14 +487,14 @@ asocket* host_service_to_socket(const char* name, const char* serial, TransportI
return nullptr;
}
- int fd = create_service_thread(wait_for_state, sinfo.get());
+ int fd = create_service_thread("wait", wait_for_state, sinfo.get());
if (fd != -1) {
sinfo.release();
}
return create_local_socket(fd);
} else if (!strncmp(name, "connect:", 8)) {
char* host = strdup(name + 8);
- int fd = create_service_thread(connect_service, host);
+ int fd = create_service_thread("connect", connect_service, host);
if (fd == -1) {
free(host);
}
diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp
index ee821f834..5b48da029 100644
--- a/adb/shell_service.cpp
+++ b/adb/shell_service.cpp
@@ -435,8 +435,7 @@ int Subprocess::OpenPtyChildFd(const char* pts_name, unique_fd* error_sfd) {
void Subprocess::ThreadHandler(void* userdata) {
Subprocess* subprocess = reinterpret_cast<Subprocess*>(userdata);
- adb_thread_setname(android::base::StringPrintf(
- "shell srvc %d", subprocess->pid()));
+ adb_thread_setname(android::base::StringPrintf("shell svc %d", subprocess->pid()));
D("passing data streams for PID %d", subprocess->pid());
subprocess->PassDataStreams();