virtioproxy: update setting of m_networkSettings to under the lock (#14210)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

Ben Hillis committed Feb 12, 2026 at 15:39 UTC 31ecc4940cc6e961878128ed9609880124de2996
1 file changed +14 -15
src/windows/common/VirtioNetworking.cpp
+14 -15
@@ -184,7 +184,9 @@ void NETIOAPI_API_ VirtioNetworking::OnNetworkConnectivityChange(PVOID context,
184 void VirtioNetworking::RefreshGuestConnection() noexcept
185 try
186 {
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 +
190 m_networkSettings = GetHostEndpointSettings();
191
192 // TODO: Determine gateway MAC address
@@ -220,20 +222,6 @@ try
222
223 const auto newDeviceOptions = device_options.str();
224
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();
225 if (newDeviceOptions != m_trackedDeviceOptions)
226 {
227 m_trackedDeviceOptions = newDeviceOptions;
@@ -277,6 +265,16 @@ try
265 }
266
267 // 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 +
278 if (currentDns != m_trackedDnsSettings)
279 {
280 m_trackedDnsSettings = currentDns;
@@ -288,6 +286,7 @@ try
286 }
287
288 // Send MTU update if needed.
289 + const auto minMtu = GetMinimumConnectedInterfaceMtu();
290 if (minMtu && minMtu.value() != m_networkMtu)
291 {
292 m_networkMtu = minMtu.value();