mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
[android] stop immediatly if no transit tunnels available while graceful shutdown
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
65e1871cd7
commit
c0de9455bb
|
@ -4,6 +4,7 @@
|
|||
#include "RouterContext.h"
|
||||
#include "ClientContext.h"
|
||||
#include "Transports.h"
|
||||
#include "Tunnel.h"
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
|
@ -98,3 +99,8 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
|
|||
// Set DataDir
|
||||
i2p::android::SetDataDir(dataDir);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
return i2p::tunnel::tunnels.CountTransitTunnels();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
|
|||
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
|
||||
(JNIEnv *env, jclass clazz, jstring jdataDir);
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_GetTransitTunnelsCount
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -65,6 +65,10 @@ public class DaemonSingleton {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized int GetTransitTunnelsCount() {
|
||||
return I2PD_JNI.GetTransitTunnelsCount();
|
||||
}
|
||||
|
||||
private volatile boolean startedOkay;
|
||||
|
||||
public enum State {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class I2PDActivity extends Activity {
|
|||
processAssets();
|
||||
runOnUiThread(() -> {
|
||||
try {
|
||||
if (textView==null)
|
||||
if (textView == null)
|
||||
return;
|
||||
Throwable tr = daemon.getLastThrowable();
|
||||
if (tr!=null) {
|
||||
|
@ -128,7 +128,7 @@ public class I2PDActivity extends Activity {
|
|||
doBindService();
|
||||
|
||||
final Timer gracefulQuitTimer = getGracefulQuitTimer();
|
||||
if (gracefulQuitTimer!=null) {
|
||||
if (gracefulQuitTimer != null) {
|
||||
long gracefulStopAtMillis;
|
||||
synchronized (graceStartedMillis_LOCK) {
|
||||
gracefulStopAtMillis = graceStartedMillis + GRACEFUL_DELAY_MILLIS;
|
||||
|
@ -373,6 +373,11 @@ public class I2PDActivity extends Activity {
|
|||
if (gracefulQuitTimerOld != null)
|
||||
gracefulQuitTimerOld.cancel();
|
||||
|
||||
if(daemon.GetTransitTunnelsCount() <= 0) { // no tunnels left
|
||||
Log.d(TAG, "no transit tunnels left, stopping");
|
||||
i2pdStop();
|
||||
}
|
||||
|
||||
final Timer gracefulQuitTimer = new Timer(true);
|
||||
setGracefulQuitTimer(gracefulQuitTimer);
|
||||
gracefulQuitTimer.schedule(new TimerTask() {
|
||||
|
@ -480,7 +485,7 @@ public class I2PDActivity extends Activity {
|
|||
private void deleteRecursive(File fileOrDirectory) {
|
||||
if (fileOrDirectory.isDirectory()) {
|
||||
File[] files = fileOrDirectory.listFiles();
|
||||
if (files!=null) {
|
||||
if (files != null) {
|
||||
for (File child : files) {
|
||||
deleteRecursive(child);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ public class I2PD_JNI {
|
|||
|
||||
public static native void setDataDir(String jdataDir);
|
||||
|
||||
public static native int GetTransitTunnelsCount();
|
||||
|
||||
public static void loadLibraries() {
|
||||
//System.loadLibrary("c++_shared");
|
||||
System.loadLibrary("i2pd");
|
||||
|
|
Loading…
Reference in a new issue