Enhanced the migrate connection code to resolve issues with NWConnection leaks. Additionally, implemented validation measures to avert the occurrence of reconnection loops.
Why is the change necessary?
Certain modifications have been implemented to address memory leaks during the execution of the migrateConnection function. However, the key alteration revolves around cases where the NWConnection instance on iOS is unexpectedly disposed of. In such instances, regardless of the number of reconnection attempts, they are destined to fail due to the connection's disposal. To counteract this situation, a safeguard has been introduced to detect entry into this reconnection loop. Consequently, the connection is deliberately dismantled, paving the way for the establishment of a fresh NWConnection instance, enabling subsequent reconnection attempts to succeed.
Description of the pull request
Enhanced the migrate connection code to resolve issues with
NWConnection
leaks. Additionally, implemented validation measures to avert the occurrence of reconnection loops.Why is the change necessary?
Certain modifications have been implemented to address memory leaks during the execution of the
migrateConnection
function. However, the key alteration revolves around cases where theNWConnection
instance on iOS is unexpectedly disposed of. In such instances, regardless of the number of reconnection attempts, they are destined to fail due to the connection's disposal. To counteract this situation, a safeguard has been introduced to detect entry into this reconnection loop. Consequently, the connection is deliberately dismantled, paving the way for the establishment of a freshNWConnection
instance, enabling subsequent reconnection attempts to succeed.