File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
debug_router/native/socket Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,14 @@ void SocketServerPosix::Start() {
9494 NotifyInit (GetErrorMessage (), " accept socket error" );
9595 return ;
9696 }
97- auto temp_usb_client = std::make_shared<UsbClient>(accept_socket_fd);
97+ if (temp_usb_client_) {
98+ temp_usb_client_->Stop ();
99+ }
100+ temp_usb_client_ = std::make_shared<UsbClient>(accept_socket_fd);
98101 std::shared_ptr<ClientListener> listener =
99102 std::make_shared<ClientListener>(shared_from_this ());
100- temp_usb_client ->Init ();
101- temp_usb_client ->StartUp (listener);
103+ temp_usb_client_ ->Init ();
104+ temp_usb_client_ ->StartUp (listener);
102105}
103106
104107void SocketServerPosix::CloseSocket (int socket_fd) {
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ void SocketServer::Close() {
127127void SocketServer::Disconnect () {
128128 thread::DebugRouterExecutor::GetInstance ().Post ([=]() {
129129 if (!usb_client_) {
130+ usb_client_->Stop ();
130131 usb_client_ = nullptr ;
131132 }
132133 });
@@ -136,6 +137,9 @@ SocketServer::~SocketServer() {
136137 if (!usb_client_) {
137138 usb_client_->Stop ();
138139 }
140+ if (!temp_usb_client_) {
141+ temp_usb_client_->Stop ();
142+ }
139143 Close ();
140144}
141145
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ class SocketServer : public std::enable_shared_from_this<SocketServer> {
6565 std::unique_ptr<CountDownLatch> latch_;
6666 std::mutex queue_lock_;
6767 std::shared_ptr<UsbClient> usb_client_;
68+ std::shared_ptr<UsbClient> temp_usb_client_;
6869
6970 volatile SocketType socket_fd_ = kInvalidSocket ;
7071};
You can’t perform that action at this time.
0 commit comments