Commit a41bc4f4 authored by Daniel Wolf's avatar Daniel Wolf

Don't set anything which has to be reused to null in cleanup. It might be used...

Don't set anything which has to be reused to null in cleanup. It might be used in other calls to run() afterwards
parent e327d672
......@@ -108,7 +108,6 @@ class ForwardedPacketStore(var logger: Logger?) {
_forwardedPollablePackets.clear()
newlyForwardedPackets.clear()
newlyForwardedNonPollablePackets.clear()
logger = null
}
}
......
......@@ -236,10 +236,15 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
fun stop() {
logger?.info("stop() called")
if (!proxyStopped) {
shouldRun = false
proxyStopped = true
val wasThreadRunning = proxyThread?.isAlive ?: false
shouldRun = false
packetProxy.stop()
cleanup()
if(!wasThreadRunning) {
forwardedPacketStore?.clear()
forwardedPacketStore = null
}
tunnelHandle?.clear(true)
tunnelHandle = null
deviceInput?.closeSilently()
......@@ -249,17 +254,7 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
private fun cleanup() {
logger?.info { "cleanup() called" }
proxyThread?.interrupt() ?: run {
if (Looper.getMainLooper().thread == Thread.currentThread()) {
GlobalScope.launch {
forwardedPacketStore?.clear()
forwardedPacketStore = null
}
} else {
forwardedPacketStore?.clear()
forwardedPacketStore = null
}
}
proxyThread?.interrupt()
nonPollableProxyThread?.interrupt()
exceptionCallbacks.clear()
}
......@@ -273,7 +268,6 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
pipesToClose.clear()
forwardedPacketStore?.clear()
tunnelHandle?.clear(false)
forwardedPacketStore = null
}
@Throws(ErrnoException::class)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment