1
0
mirror of https://github.com/moparisthebest/SSLDroid synced 2024-11-30 04:42:17 -05:00

Try to wait() for the workerthreads to finish when stopping the

service, this probably needs more thought in the future

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-04-20 19:01:19 +02:00
parent 780d221b2f
commit 82da2651b2

View File

@ -186,11 +186,19 @@ public class TcpProxyServerThread extends Thread {
} }
public void run() { public void run() {
while (true) { while (true) {
try { try {
Thread fromBrowserToServer = null;
Thread fromServerToBrowser = null;
if (isInterrupted()){ if (isInterrupted()){
Log.d("SSLDroid", "Interrupted server thread, closing sockets..."); Log.d("SSLDroid", "Interrupted server thread, closing sockets...");
ss.close(); ss.close();
if (fromBrowserToServer != null)
fromBrowserToServer.wait();
if (fromServerToBrowser != null)
fromServerToBrowser.wait();
return; return;
} }
// accept the connection from my client // accept the connection from my client
@ -220,16 +228,16 @@ public class TcpProxyServerThread extends Thread {
+ tunnelHost + " ..."); + tunnelHost + " ...");
// relay the stuff thru // relay the stuff thru
Thread fromBrowserToServer = new Relay( fromBrowserToServer = new Relay(
sc.getInputStream(), st.getOutputStream()); sc.getInputStream(), st.getOutputStream());
Thread fromServerToBrowser = new Relay( fromServerToBrowser = new Relay(
st.getInputStream(), sc.getOutputStream()); st.getInputStream(), sc.getOutputStream());
fromBrowserToServer.start(); fromBrowserToServer.start();
fromServerToBrowser.start(); fromServerToBrowser.start();
} catch (Exception ee) { } catch (Exception ee) {
Log.d("SSLDroid", "Ouch: " + ee.toString()); Log.d("SSLDroid", "Ouch: " + ee.getMessage());
createNotification(ee.getMessage(), "Ouch: "+ee.toString()); createNotification(ee.getMessage(), "Ouch: "+ee.toString());
//ttg.doLog("Ouch: " + ee.toString()); //ttg.doLog("Ouch: " + ee.toString());
} }