Loading adb/client/usb_linux.cpp +2 −4 Original line number Original line Diff line number Diff line Loading @@ -574,7 +574,7 @@ static void register_device(const char* dev_name, const char* dev_path, register_usb_transport(done_usb, serial.c_str(), dev_path, done_usb->writeable); register_usb_transport(done_usb, serial.c_str(), dev_path, done_usb->writeable); } } static void device_poll_thread(void*) { static void device_poll_thread() { adb_thread_setname("device poll"); adb_thread_setname("device poll"); D("Created device thread"); D("Created device thread"); while (true) { while (true) { Loading @@ -593,8 +593,6 @@ void usb_init() { actions.sa_handler = [](int) {}; actions.sa_handler = [](int) {}; sigaction(SIGALRM, &actions, nullptr); sigaction(SIGALRM, &actions, nullptr); if (!adb_thread_create(device_poll_thread, nullptr)) { std::thread(device_poll_thread).detach(); fatal_errno("cannot create device_poll thread"); } } } } // namespace native } // namespace native adb/client/usb_osx.cpp +2 −4 Original line number Original line Diff line number Diff line Loading @@ -405,7 +405,7 @@ err_get_num_ep: std::mutex& operate_device_lock = *new std::mutex(); std::mutex& operate_device_lock = *new std::mutex(); static void RunLoopThread(void* unused) { static void RunLoopThread() { adb_thread_setname("RunLoop"); adb_thread_setname("RunLoop"); VLOG(USB) << "RunLoopThread started"; VLOG(USB) << "RunLoopThread started"; Loading Loading @@ -436,9 +436,7 @@ void usb_init() { usb_inited_flag = false; usb_inited_flag = false; if (!adb_thread_create(RunLoopThread, nullptr)) { std::thread(RunLoopThread).detach(); fatal_errno("cannot create RunLoop thread"); } // Wait for initialization to finish // Wait for initialization to finish while (!usb_inited_flag) { while (!usb_inited_flag) { Loading adb/client/usb_windows.cpp +5 −9 Original line number Original line Diff line number Diff line Loading @@ -103,7 +103,7 @@ static void kick_devices(); /// Entry point for thread that polls (every second) for new usb interfaces. /// Entry point for thread that polls (every second) for new usb interfaces. /// This routine calls find_devices in infinite loop. /// This routine calls find_devices in infinite loop. static void device_poll_thread(void*); static void device_poll_thread(); /// Initializes this module /// Initializes this module void usb_init(); void usb_init(); Loading Loading @@ -174,7 +174,7 @@ int register_new_device(usb_handle* handle) { return 1; return 1; } } void device_poll_thread(void*) { void device_poll_thread() { adb_thread_setname("Device Poll"); adb_thread_setname("Device Poll"); D("Created device thread"); D("Created device thread"); Loading Loading @@ -203,7 +203,7 @@ static LRESULT CALLBACK _power_window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, return DefWindowProcW(hwnd, uMsg, wParam, lParam); return DefWindowProcW(hwnd, uMsg, wParam, lParam); } } static void _power_notification_thread(void*) { static void _power_notification_thread() { // This uses a thread with its own window message pump to get power // This uses a thread with its own window message pump to get power // notifications. If adb runs from a non-interactive service account, this // notifications. If adb runs from a non-interactive service account, this // might not work (not sure). If that happens to not work, we could use // might not work (not sure). If that happens to not work, we could use Loading Loading @@ -258,12 +258,8 @@ static void _power_notification_thread(void*) { } } void usb_init() { void usb_init() { if (!adb_thread_create(device_poll_thread, nullptr)) { std::thread(device_poll_thread).detach(); fatal_errno("cannot create device poll thread"); std::thread(_power_notification_thread).detach(); } if (!adb_thread_create(_power_notification_thread, nullptr)) { fatal_errno("cannot create power notification thread"); } } } usb_handle* do_usb_open(const wchar_t* interface_name) { usb_handle* do_usb_open(const wchar_t* interface_name) { Loading adb/commandline.cpp +2 −7 Original line number Original line Diff line number Diff line Loading @@ -655,13 +655,8 @@ static int RemoteShell(bool use_shell_protocol, const std::string& type_arg, #endif #endif // TODO: combine read_and_dump with stdin_read_thread to make life simpler? // TODO: combine read_and_dump with stdin_read_thread to make life simpler? int exit_code = 1; std::thread(stdin_read_thread_loop, args).detach(); if (!adb_thread_create(stdin_read_thread_loop, args)) { int exit_code = read_and_dump(fd, use_shell_protocol); PLOG(ERROR) << "error starting stdin read thread"; delete args; } else { exit_code = read_and_dump(fd, use_shell_protocol); } // TODO: properly exit stdin_read_thread_loop and close |fd|. // TODO: properly exit stdin_read_thread_loop and close |fd|. Loading adb/daemon/mdns.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -17,12 +17,14 @@ #include "adb_mdns.h" #include "adb_mdns.h" #include "sysdeps.h" #include "sysdeps.h" #include <chrono> #include <dns_sd.h> #include <dns_sd.h> #include <endian.h> #include <endian.h> #include <mutex> #include <unistd.h> #include <unistd.h> #include <chrono> #include <mutex> #include <thread> #include <android-base/logging.h> #include <android-base/logging.h> #include <android-base/properties.h> #include <android-base/properties.h> Loading Loading @@ -58,7 +60,7 @@ static void mdns_callback(DNSServiceRef /*ref*/, } } } } static void setup_mdns_thread(void* /* unused */) { static void setup_mdns_thread() { start_mdns(); start_mdns(); std::lock_guard<std::mutex> lock(mdns_lock); std::lock_guard<std::mutex> lock(mdns_lock); Loading Loading @@ -88,7 +90,7 @@ static void teardown_mdns() { void setup_mdns(int port_in) { void setup_mdns(int port_in) { port = port_in; port = port_in; adb_thread_create(setup_mdns_thread, nullptr, nullptr); std::thread(setup_mdns_thread).detach(); // TODO: Make this more robust against a hard kill. // TODO: Make this more robust against a hard kill. atexit(teardown_mdns); atexit(teardown_mdns); Loading Loading
adb/client/usb_linux.cpp +2 −4 Original line number Original line Diff line number Diff line Loading @@ -574,7 +574,7 @@ static void register_device(const char* dev_name, const char* dev_path, register_usb_transport(done_usb, serial.c_str(), dev_path, done_usb->writeable); register_usb_transport(done_usb, serial.c_str(), dev_path, done_usb->writeable); } } static void device_poll_thread(void*) { static void device_poll_thread() { adb_thread_setname("device poll"); adb_thread_setname("device poll"); D("Created device thread"); D("Created device thread"); while (true) { while (true) { Loading @@ -593,8 +593,6 @@ void usb_init() { actions.sa_handler = [](int) {}; actions.sa_handler = [](int) {}; sigaction(SIGALRM, &actions, nullptr); sigaction(SIGALRM, &actions, nullptr); if (!adb_thread_create(device_poll_thread, nullptr)) { std::thread(device_poll_thread).detach(); fatal_errno("cannot create device_poll thread"); } } } } // namespace native } // namespace native
adb/client/usb_osx.cpp +2 −4 Original line number Original line Diff line number Diff line Loading @@ -405,7 +405,7 @@ err_get_num_ep: std::mutex& operate_device_lock = *new std::mutex(); std::mutex& operate_device_lock = *new std::mutex(); static void RunLoopThread(void* unused) { static void RunLoopThread() { adb_thread_setname("RunLoop"); adb_thread_setname("RunLoop"); VLOG(USB) << "RunLoopThread started"; VLOG(USB) << "RunLoopThread started"; Loading Loading @@ -436,9 +436,7 @@ void usb_init() { usb_inited_flag = false; usb_inited_flag = false; if (!adb_thread_create(RunLoopThread, nullptr)) { std::thread(RunLoopThread).detach(); fatal_errno("cannot create RunLoop thread"); } // Wait for initialization to finish // Wait for initialization to finish while (!usb_inited_flag) { while (!usb_inited_flag) { Loading
adb/client/usb_windows.cpp +5 −9 Original line number Original line Diff line number Diff line Loading @@ -103,7 +103,7 @@ static void kick_devices(); /// Entry point for thread that polls (every second) for new usb interfaces. /// Entry point for thread that polls (every second) for new usb interfaces. /// This routine calls find_devices in infinite loop. /// This routine calls find_devices in infinite loop. static void device_poll_thread(void*); static void device_poll_thread(); /// Initializes this module /// Initializes this module void usb_init(); void usb_init(); Loading Loading @@ -174,7 +174,7 @@ int register_new_device(usb_handle* handle) { return 1; return 1; } } void device_poll_thread(void*) { void device_poll_thread() { adb_thread_setname("Device Poll"); adb_thread_setname("Device Poll"); D("Created device thread"); D("Created device thread"); Loading Loading @@ -203,7 +203,7 @@ static LRESULT CALLBACK _power_window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, return DefWindowProcW(hwnd, uMsg, wParam, lParam); return DefWindowProcW(hwnd, uMsg, wParam, lParam); } } static void _power_notification_thread(void*) { static void _power_notification_thread() { // This uses a thread with its own window message pump to get power // This uses a thread with its own window message pump to get power // notifications. If adb runs from a non-interactive service account, this // notifications. If adb runs from a non-interactive service account, this // might not work (not sure). If that happens to not work, we could use // might not work (not sure). If that happens to not work, we could use Loading Loading @@ -258,12 +258,8 @@ static void _power_notification_thread(void*) { } } void usb_init() { void usb_init() { if (!adb_thread_create(device_poll_thread, nullptr)) { std::thread(device_poll_thread).detach(); fatal_errno("cannot create device poll thread"); std::thread(_power_notification_thread).detach(); } if (!adb_thread_create(_power_notification_thread, nullptr)) { fatal_errno("cannot create power notification thread"); } } } usb_handle* do_usb_open(const wchar_t* interface_name) { usb_handle* do_usb_open(const wchar_t* interface_name) { Loading
adb/commandline.cpp +2 −7 Original line number Original line Diff line number Diff line Loading @@ -655,13 +655,8 @@ static int RemoteShell(bool use_shell_protocol, const std::string& type_arg, #endif #endif // TODO: combine read_and_dump with stdin_read_thread to make life simpler? // TODO: combine read_and_dump with stdin_read_thread to make life simpler? int exit_code = 1; std::thread(stdin_read_thread_loop, args).detach(); if (!adb_thread_create(stdin_read_thread_loop, args)) { int exit_code = read_and_dump(fd, use_shell_protocol); PLOG(ERROR) << "error starting stdin read thread"; delete args; } else { exit_code = read_and_dump(fd, use_shell_protocol); } // TODO: properly exit stdin_read_thread_loop and close |fd|. // TODO: properly exit stdin_read_thread_loop and close |fd|. Loading
adb/daemon/mdns.cpp +6 −4 Original line number Original line Diff line number Diff line Loading @@ -17,12 +17,14 @@ #include "adb_mdns.h" #include "adb_mdns.h" #include "sysdeps.h" #include "sysdeps.h" #include <chrono> #include <dns_sd.h> #include <dns_sd.h> #include <endian.h> #include <endian.h> #include <mutex> #include <unistd.h> #include <unistd.h> #include <chrono> #include <mutex> #include <thread> #include <android-base/logging.h> #include <android-base/logging.h> #include <android-base/properties.h> #include <android-base/properties.h> Loading Loading @@ -58,7 +60,7 @@ static void mdns_callback(DNSServiceRef /*ref*/, } } } } static void setup_mdns_thread(void* /* unused */) { static void setup_mdns_thread() { start_mdns(); start_mdns(); std::lock_guard<std::mutex> lock(mdns_lock); std::lock_guard<std::mutex> lock(mdns_lock); Loading Loading @@ -88,7 +90,7 @@ static void teardown_mdns() { void setup_mdns(int port_in) { void setup_mdns(int port_in) { port = port_in; port = port_in; adb_thread_create(setup_mdns_thread, nullptr, nullptr); std::thread(setup_mdns_thread).detach(); // TODO: Make this more robust against a hard kill. // TODO: Make this more robust against a hard kill. atexit(teardown_mdns); atexit(teardown_mdns); Loading