UPnP: breadcrumb before the router teardown calls so a hang names itself in the log

This commit is contained in:
Ednunp
2026-07-18 09:21:58 +01:00
parent 8fe52047be
commit a3b8f1659b
+5
View File
@@ -209,6 +209,7 @@ internal sealed class RouterPortMapper : IDisposable
if (disposed) return; if (disposed) return;
} }
RemoveMappingBestEffort(); RemoveMappingBestEffort();
log?.Invoke("UPnP: stopping discovery...");
try { NatUtility.StopDiscovery(); } catch { /* ignore */ } try { NatUtility.StopDiscovery(); } catch { /* ignore */ }
try { NatUtility.DeviceFound -= OnDeviceFound; } catch { /* ignore */ } try { NatUtility.DeviceFound -= OnDeviceFound; } catch { /* ignore */ }
lock (gate) lock (gate)
@@ -307,6 +308,10 @@ internal sealed class RouterPortMapper : IDisposable
if (d is null || m is null) return; if (d is null || m is null) return;
try try
{ {
// Breadcrumb BEFORE the call: DeletePortMap is a synchronous request to the router and is the
// usual suspect when close hangs. The log flushes each line, so if this blocks with no reply the
// last line in the log names it (and which NAT protocol) instead of leaving us guessing.
log?.Invoke($"UPnP: removing port mapping via {d.GetType().Name} (port {AudioPort})...");
d.DeletePortMap(m); d.DeletePortMap(m);
log?.Invoke($"UPnP mapping removed (port {AudioPort})"); log?.Invoke($"UPnP mapping removed (port {AudioPort})");
} }