We're working on Packet Tunnel Provider on iOS and I was wondering about the process life cycle, in particular when a connection is stopped.
There's some house-keeping I'd like to do when the connection has stopped, which may take up to a few seconds. It seems on iOS, the Network Extension process is terminated shortly after the completion handler of - stopTunnelWithReason:completionHandler:
has been called.
Since the house-keeping is not strictly a part of stopping the connection and I would like to allow the user to start a new connection as soon as possible: is there a way to tell the Network Extension to keep the process alive (for a while)? Or do I have to do it before calling the completion handler of - stopTunnelWithReason:completionHandler:
?
Related question: when there's an error and we need to stop the connection "from within" the NE, we're supposed to call - cancelTunnelWithError:
. What's the lifecycle here? Do we need to tear everything down, do the house-keeping, and only then call - cancelTunnelWithError:
? Or can we call - cancelTunnelWithError:
and then continue to clean everything up?
I would like to allow the user to start a new connection as soon as possible: is there a way to tell the Network Extension to keep the process alive (for a while)? Or do I have to do it before calling the completion handler of - stopTunnelWithReason:completionHandler:?
Since the user is starting the connection, what is wrong with having the user initiate the connection from either the container app or the VPN Settings in the Settings app?
As for keeping the process alive, no, stopTunnelWithReason
is call as part of the process to destroy the packet tunnel provider so any attempts to keep the process alive could end up with strange behavior.
Regarding:
What's the lifecycle here? Do we need to tear everything down, do the house-keeping, and only then call - cancelTunnelWithError:? Or can we call - cancelTunnelWithError: and then continue to clean everything up?
Tear everything down, do house-keeping, and then call cancelTunnelWithError
.
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com