mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 04:02:15 +02:00
Allow OpenVPNClientThread.wait_thread() to be called repeatedly
without issue.
This commit is contained in:
parent
bc02566ed9
commit
17ba45b487
@ -1,7 +1,7 @@
|
||||
public class OpenVPNClientThread extends OpenVPNClientBase implements Runnable {
|
||||
private EventReceiver parent;
|
||||
private Status connect_status;
|
||||
private Thread thread;
|
||||
private Status connect_status;
|
||||
|
||||
public interface EventReceiver {
|
||||
void event(Event event);
|
||||
@ -10,6 +10,8 @@ public class OpenVPNClientThread extends OpenVPNClientBase implements Runnable {
|
||||
|
||||
public OpenVPNClientThread() {
|
||||
parent = null;
|
||||
thread = null;
|
||||
connect_status = null;
|
||||
}
|
||||
|
||||
// start connect session in worker thread
|
||||
@ -28,22 +30,23 @@ public class OpenVPNClientThread extends OpenVPNClientBase implements Runnable {
|
||||
// wait for worker thread to complete; to stop thread,
|
||||
// first call super stop() method then wait_thread().
|
||||
public Status wait_thread() {
|
||||
boolean interrupted;
|
||||
do {
|
||||
interrupted = false;
|
||||
try {
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
super.stop(); // send thread a stop message
|
||||
}
|
||||
} while (interrupted);
|
||||
|
||||
// dissassociate client callbacks from parent
|
||||
parent = null;
|
||||
thread = null;
|
||||
if (thread != null) {
|
||||
boolean interrupted;
|
||||
do {
|
||||
interrupted = false;
|
||||
try {
|
||||
thread.join();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
super.stop(); // send thread a stop message
|
||||
}
|
||||
} while (interrupted);
|
||||
|
||||
// dissassociate client callbacks from parent
|
||||
parent = null;
|
||||
thread = null;
|
||||
}
|
||||
return connect_status;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user