fix Shell calls so that we close() shell when done

This commit is contained in:
Nathan Freitas 2014-04-08 01:12:56 -04:00
parent e78486a41f
commit c9bf8d2585
2 changed files with 23 additions and 12 deletions

View File

@ -434,10 +434,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
private void killTorProcess () throws Exception
{
StringBuilder log = new StringBuilder();
int procId = -1;
if (conn != null)
@ -457,7 +455,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
conn = null;
}
int killDelayMs = 300;
int maxTry = 5;
int currTry = 0;
@ -481,7 +478,6 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
logNotice("Found Privoxy PID=" + procId + " - killing now...");
tb.killAll(filePrivoxy.getCanonicalPath());
}
@ -489,14 +485,11 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{
logNotice("Found ObfsProxy PID=" + procId + " - killing now...");
tb.killAll(fileObfsProxy.getCanonicalPath());
}
}
else
{
throw new Exception("*** Unable to kill existing Tor process. Please REBOOT your device. ***");
}
shell.close();
}
private void logNotice (String msg)
@ -569,6 +562,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
File fileTest = new File(fileBin.getCanonicalPath());
logNotice(fileTest.getName() + ": POST: Is binary exec? " + fileTest.canExecute());
shell.close();
}
return fileBin.canExecute();
@ -751,6 +746,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
}
}
shell.close();
if (procId == -1)
{
@ -809,7 +806,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
logNotice("Privoxy process id=" + privoxyProcId);
shell.close();
}

View File

@ -393,6 +393,8 @@ public class TorTransProxy implements TorServiceConstants {
fixTransproxyLeak (context);
shell.close();
return 1;
}
@ -432,6 +434,8 @@ public class TorTransProxy implements TorServiceConstants {
}
shell.close();
return 0;
}
@ -471,7 +475,11 @@ public class TorTransProxy implements TorServiceConstants {
shell.add(cmd);
return cmd.getExitCode();
int exitCode = cmd.getExitCode();
shell.close();
return exitCode;
}
public int fixTransproxyLeak (Context context) throws Exception
@ -490,6 +498,8 @@ public class TorTransProxy implements TorServiceConstants {
script.append(" -I OUTPUT ! -o lo ! -d 127.0.0.1 ! -s 127.0.0.1 -p tcp -m tcp --tcp-flags ACK,RST ACK,RST -j DROP");
shell.add(new SimpleCommand(script.toString()));
shell.close();
return 1;
}
@ -642,7 +652,11 @@ public class TorTransProxy implements TorServiceConstants {
fixTransproxyLeak (context);
return cmd.getExitCode();
int exitCode = cmd.getExitCode();
shell.close();
return exitCode;
}