From c3c9a7ffc99869d86ad77568fb87f0cda27953d9 Mon Sep 17 00:00:00 2001 From: hai007 Date: Tue, 20 Dec 2022 14:17:08 -0800 Subject: [PATCH] Extend endpoint disconnection timeout. This extends the endpoint disconnection timeout to be slightly longer than the WebRTC connection attempt timeout. This allows an in-progress bandwidth upgrade to resolve before we clean up the endpoint. Failing to properly clean up the bandwidth upgrade can lead to a delay when shutting down Nearby Connections and can crash the process instead of allowing a clean shutdown. PiperOrigin-RevId: 496750001 --- connections/implementation/endpoint_manager.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connections/implementation/endpoint_manager.h b/connections/implementation/endpoint_manager.h index dd127d73..a4931476 100644 --- a/connections/implementation/endpoint_manager.h +++ b/connections/implementation/endpoint_manager.h @@ -238,8 +238,11 @@ class EndpointManager { static void WaitForLatch(const std::string& method_name, CountDownLatch* latch, std::int32_t timeout_millis); + // We set this to 11s to provide sufficient time for an in-progress WebRTC + // bandwidth upgrade to resolve. This is chosen to be slightly longer than the + // 10s timeout in WebRtc::AttemptToConnect(). static constexpr absl::Duration kProcessEndpointDisconnectionTimeout = - absl::Milliseconds(2000); + absl::Milliseconds(11000); static constexpr absl::Time kInvalidTimestamp = absl::InfinitePast(); // It should be noted that this method may be called multiple times (because