summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'adb/transport.cpp')
-rw-r--r--adb/transport.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/adb/transport.cpp b/adb/transport.cpp
index b45c43f89..922200826 100644
--- a/adb/transport.cpp
+++ b/adb/transport.cpp
@@ -81,6 +81,7 @@ class SCOPED_CAPABILITY ScopedAssumeLocked {
81 ~ScopedAssumeLocked() RELEASE() {} 81 ~ScopedAssumeLocked() RELEASE() {}
82}; 82};
83 83
84#if ADB_HOST
84// Tracks and handles atransport*s that are attempting reconnection. 85// Tracks and handles atransport*s that are attempting reconnection.
85class ReconnectHandler { 86class ReconnectHandler {
86 public: 87 public:
@@ -224,6 +225,8 @@ void ReconnectHandler::Run() {
224 225
225static auto& reconnect_handler = *new ReconnectHandler(); 226static auto& reconnect_handler = *new ReconnectHandler();
226 227
228#endif
229
227} // namespace 230} // namespace
228 231
229TransportId NextTransportId() { 232TransportId NextTransportId() {
@@ -697,9 +700,11 @@ static void transport_registration_func(int _fd, unsigned ev, void*) {
697 update_transports(); 700 update_transports();
698} 701}
699 702
703#if ADB_HOST
700void init_reconnect_handler(void) { 704void init_reconnect_handler(void) {
701 reconnect_handler.Start(); 705 reconnect_handler.Start();
702} 706}
707#endif
703 708
704void init_transport_registration(void) { 709void init_transport_registration(void) {
705 int s[2]; 710 int s[2];
@@ -718,7 +723,9 @@ void init_transport_registration(void) {
718} 723}
719 724
720void kick_all_transports() { 725void kick_all_transports() {
726#if ADB_HOST
721 reconnect_handler.Stop(); 727 reconnect_handler.Stop();
728#endif
722 // To avoid only writing part of a packet to a transport after exit, kick all transports. 729 // To avoid only writing part of a packet to a transport after exit, kick all transports.
723 std::lock_guard<std::recursive_mutex> lock(transport_lock); 730 std::lock_guard<std::recursive_mutex> lock(transport_lock);
724 for (auto t : transport_list) { 731 for (auto t : transport_list) {
@@ -756,13 +763,19 @@ static void transport_unref(atransport* t) {
756 t->ref_count--; 763 t->ref_count--;
757 if (t->ref_count == 0) { 764 if (t->ref_count == 0) {
758 t->connection()->Stop(); 765 t->connection()->Stop();
766#if ADB_HOST
759 if (t->IsTcpDevice() && !t->kicked()) { 767 if (t->IsTcpDevice() && !t->kicked()) {
760 D("transport: %s unref (attempting reconnection) %d", t->serial.c_str(), t->kicked()); 768 D("transport: %s unref (attempting reconnection)", t->serial.c_str());
761 reconnect_handler.TrackTransport(t); 769 reconnect_handler.TrackTransport(t);
762 } else { 770 } else {
763 D("transport: %s unref (kicking and closing)", t->serial.c_str()); 771 D("transport: %s unref (kicking and closing)", t->serial.c_str());
764 remove_transport(t); 772 remove_transport(t);
765 } 773 }
774#else
775 D("transport: %s unref (kicking and closing)", t->serial.c_str());
776 remove_transport(t);
777#endif
778
766 } else { 779 } else {
767 D("transport: %s unref (count=%zu)", t->serial.c_str(), t->ref_count); 780 D("transport: %s unref (count=%zu)", t->serial.c_str(), t->ref_count);
768 } 781 }