From cab81192e742913d88f766dc1f27a1c8d6addfb6 Mon Sep 17 00:00:00 2001 From: iuriionishchenko <136322748+iuriionishchenko@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:57:11 +0300 Subject: [PATCH] Rework of DIAL service restarting (#2849) Rework of DIAL service restarting To avoid IP address conflicts an existing DIAL service must be destroyed before a new DIAL service has been created b/268088112 Change-Id: I9740e9e3997ac0db0fbc1b6bebc170eebe51812a (cherry picked from commit ca4dc03ac5eb2898dcc1142ef00f00bb39842c28) --- cobalt/network/network_module.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cobalt/network/network_module.cc b/cobalt/network/network_module.cc index 09263af68ae4..888bbe9dc119 100644 --- a/cobalt/network/network_module.cc +++ b/cobalt/network/network_module.cc @@ -249,7 +249,12 @@ void NetworkModule::RestartDialService() { } void NetworkModule::OnRestartDialService(base::WaitableEvent* creation_event) { - dial_service_.reset(new DialService()); + // A new DialService instance cannot be created if any already exists + // since they will use the same address and it will cause some socket errors. + // Destroy existing service first. + dial_service_.reset(); + // Create new dial service + dial_service_ = std::make_unique(); dial_service_proxy_->ReplaceDialService(dial_service_->AsWeakPtr()); creation_event->Signal(); }