From fd810923925ed8cb8ff0481ad902cf0145f141f9 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 25 May 2022 14:59:12 -0700 Subject: [PATCH] [AltServer] Fixes NetworkConnection strong reference cycle WirelessConnection.nwConnection.stateUpdateHandler maintains strong reference to WirelessConnection, resulting in strong reference cycle. To break it, we now explicitly set stateUpdateHandler to nil when disconnecting. --- AltServer/Connections/WirelessConnectionHandler.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AltServer/Connections/WirelessConnectionHandler.swift b/AltServer/Connections/WirelessConnectionHandler.swift index 9efb1d23..1db96c54 100644 --- a/AltServer/Connections/WirelessConnectionHandler.swift +++ b/AltServer/Connections/WirelessConnectionHandler.swift @@ -144,5 +144,10 @@ private extension WirelessConnectionHandler connection.disconnect() self.disconnectionHandler?(connection) + + if let networkConnection = connection as? NetworkConnection + { + networkConnection.nwConnection.stateUpdateHandler = nil + } } }