Skip to content

Commit 31ecc49

Browse files
benhillisBen Hillis
andauthored
virtioproxy: update setting of m_networkSettings to under the lock (#14210)
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
1 parent 66822ce commit 31ecc49

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/windows/common/VirtioNetworking.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ void NETIOAPI_API_ VirtioNetworking::OnNetworkConnectivityChange(PVOID context,
184184
void VirtioNetworking::RefreshGuestConnection() noexcept
185185
try
186186
{
187-
// Query current networking information before acquiring the lock.
187+
// Acquire the lock and perform device updates.
188+
auto lock = m_lock.lock_exclusive();
189+
188190
m_networkSettings = GetHostEndpointSettings();
189191

190192
// TODO: Determine gateway MAC address
@@ -220,20 +222,6 @@ try
220222

221223
const auto newDeviceOptions = device_options.str();
222224

223-
networking::DnsInfo currentDns{};
224-
if (WI_IsFlagSet(m_flags, VirtioNetworkingFlags::DnsTunneling))
225-
{
226-
currentDns = networking::HostDnsInfo::GetDnsTunnelingSettings(default_route);
227-
}
228-
else
229-
{
230-
currentDns = networking::HostDnsInfo::GetDnsSettings(networking::DnsSettingsFlags::IncludeVpn);
231-
}
232-
233-
const auto minMtu = GetMinimumConnectedInterfaceMtu();
234-
235-
// Acquire the lock and perform device updates.
236-
auto lock = m_lock.lock_exclusive();
237225
if (newDeviceOptions != m_trackedDeviceOptions)
238226
{
239227
m_trackedDeviceOptions = newDeviceOptions;
@@ -277,6 +265,16 @@ try
277265
}
278266

279267
// Send DNS update if needed.
268+
networking::DnsInfo currentDns{};
269+
if (WI_IsFlagSet(m_flags, VirtioNetworkingFlags::DnsTunneling))
270+
{
271+
currentDns = networking::HostDnsInfo::GetDnsTunnelingSettings(default_route);
272+
}
273+
else
274+
{
275+
currentDns = networking::HostDnsInfo::GetDnsSettings(networking::DnsSettingsFlags::IncludeVpn);
276+
}
277+
280278
if (currentDns != m_trackedDnsSettings)
281279
{
282280
m_trackedDnsSettings = currentDns;
@@ -288,6 +286,7 @@ try
288286
}
289287

290288
// Send MTU update if needed.
289+
const auto minMtu = GetMinimumConnectedInterfaceMtu();
291290
if (minMtu && minMtu.value() != m_networkMtu)
292291
{
293292
m_networkMtu = minMtu.value();

0 commit comments

Comments
 (0)