From 0ff449d9fce84c71ee950f798add2a1f470ab2df Mon Sep 17 00:00:00 2001 From: Hai Shang Date: Mon, 11 Dec 2023 19:04:23 -0800 Subject: [PATCH] internal fix PiperOrigin-RevId: 590025851 --- internal/platform/implementation/g3/ble.cc | 15 +++++++-------- internal/platform/implementation/g3/ble.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/platform/implementation/g3/ble.cc b/internal/platform/implementation/g3/ble.cc index f60b2391..ed44c996 100644 --- a/internal/platform/implementation/g3/ble.cc +++ b/internal/platform/implementation/g3/ble.cc @@ -159,14 +159,13 @@ bool BleMedium::StartAdvertising( acceptance_thread_running_.exchange(true); accept_loops_runner_.Execute([&env, this, service_id]() mutable { - if (!accept_loops_runner_.InShutdown()) { - while (true) { - auto client_socket = - server_socket_->Accept(&(this->adapter_->GetPeripheral())); - if (client_socket == nullptr) break; - env.CallBleAcceptedConnectionCallback(*this, *(client_socket.release()), - service_id); - } + while (true) { + if (accept_loops_runner_.InShutdown()) break; + auto client_socket = + server_socket_->Accept(&(this->adapter_->GetPeripheral())); + if (client_socket == nullptr) break; + env.CallBleAcceptedConnectionCallback(*this, *(client_socket.release()), + service_id); } acceptance_thread_running_.exchange(false); }); diff --git a/internal/platform/implementation/g3/ble.h b/internal/platform/implementation/g3/ble.h index 243468ff..e6637005 100644 --- a/internal/platform/implementation/g3/ble.h +++ b/internal/platform/implementation/g3/ble.h @@ -184,7 +184,7 @@ class BleMedium : public api::BleMedium { std::atomic_bool acceptance_thread_running_ = false; // A thread pool dedicated to wait to complete the accept_loops_runner_. - MultiThreadExecutor close_accept_loops_runner_{kMaxConcurrentAcceptLoops}; + MultiThreadExecutor close_accept_loops_runner_{1}; // A server socket is established when start advertising. std::unique_ptr server_socket_;