Commit 588c0d57 authored by Daniel Wolf's avatar Daniel Wolf

Don't rely on isActive, use own variable instead

parent 5037705e
......@@ -63,6 +63,7 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
@Volatile
private var polling = false
var forwardingMode:ForwardingMode = ForwardingMode.MIXED
private var proxyThreadActive:Boolean = false
constructor(packetProxy: PacketProxy,
trafficStats: TrafficStats = TrafficStats(0, 0),
......@@ -129,6 +130,7 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
val eventsWriteBothActive = if(readEnd == writeEnd) 0
else OsConstants.POLLOUT
proxyThread = Thread {
proxyThreadActive = true
logger?.info("Proxy started on thread " + Thread.currentThread().name)
try {
try {
......@@ -181,6 +183,7 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
} finally {
logger?.info("Proxy thread ended.")
proxyThreadActive = false
finalizeCleanup()
}
}
......@@ -238,11 +241,10 @@ open class VPNTunnelProxy(val packetProxy: PacketProxy,
logger?.info("stop() called")
if (!proxyStopped) {
proxyStopped = true
val wasThreadRunning = proxyThread?.isAlive ?: false
shouldRun = false
packetProxy.stop()
cleanup()
if(!wasThreadRunning) {
if(!proxyThreadActive) {
forwardedPacketStore?.clear(true)
forwardedPacketStore = null
}
......
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