Check periodically for retransmittable packets. Bug #46.

This commit is contained in:
akwizgran
2014-12-14 20:26:41 +00:00
parent 29a6596ee3
commit 388b36b6be
51 changed files with 351 additions and 331 deletions

View File

@@ -46,8 +46,7 @@ class BluetoothPlugin implements DuplexPlugin {
private final Clock clock;
private final SecureRandom secureRandom;
private final DuplexPluginCallback callback;
private final int maxFrameLength;
private final long maxLatency, pollingInterval;
private final int maxFrameLength, maxLatency, pollingInterval;
private final Semaphore discoverySemaphore = new Semaphore(1);
private volatile boolean running = false;
@@ -55,8 +54,8 @@ class BluetoothPlugin implements DuplexPlugin {
private volatile LocalDevice localDevice = null;
BluetoothPlugin(Executor ioExecutor, Clock clock, SecureRandom secureRandom,
DuplexPluginCallback callback, int maxFrameLength, long maxLatency,
long pollingInterval) {
DuplexPluginCallback callback, int maxFrameLength, int maxLatency,
int pollingInterval) {
this.ioExecutor = ioExecutor;
this.clock = clock;
this.secureRandom = secureRandom;
@@ -74,13 +73,13 @@ class BluetoothPlugin implements DuplexPlugin {
return maxFrameLength;
}
public long getMaxLatency() {
public int getMaxLatency() {
return maxLatency;
}
public long getMaxIdleTime() {
public int getMaxIdleTime() {
// Bluetooth detects dead connections so we don't need keepalives
return Long.MAX_VALUE;
return Integer.MAX_VALUE;
}
public boolean start() throws IOException {
@@ -186,7 +185,7 @@ class BluetoothPlugin implements DuplexPlugin {
return true;
}
public long getPollingInterval() {
public int getPollingInterval() {
return pollingInterval;
}

View File

@@ -13,8 +13,8 @@ import org.briarproject.system.SystemClock;
public class BluetoothPluginFactory implements DuplexPluginFactory {
private static final int MAX_FRAME_LENGTH = 1024;
private static final long MAX_LATENCY = 60 * 1000; // 1 minute
private static final long POLLING_INTERVAL = 3 * 60 * 1000; // 3 minutes
private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
private static final int POLLING_INTERVAL = 3 * 60 * 1000; // 3 minutes
private final Executor ioExecutor;
private final SecureRandom secureRandom;

View File

@@ -64,11 +64,11 @@ class BluetoothTransportConnection implements DuplexTransportConnection {
return plugin.getMaxFrameLength();
}
public long getMaxLatency() {
public int getMaxLatency() {
return plugin.getMaxLatency();
}
public long getMaxIdleTime() {
public int getMaxIdleTime() {
return plugin.getMaxIdleTime();
}

View File

@@ -13,14 +13,14 @@ class PollingRemovableDriveMonitor implements RemovableDriveMonitor, Runnable {
private final Executor ioExecutor;
private final RemovableDriveFinder finder;
private final long pollingInterval;
private final int pollingInterval;
private final Object pollingLock = new Object();
private volatile boolean running = false;
private volatile Callback callback = null;
public PollingRemovableDriveMonitor(Executor ioExecutor,
RemovableDriveFinder finder, long pollingInterval) {
RemovableDriveFinder finder, int pollingInterval) {
this.ioExecutor = ioExecutor;
this.finder = finder;
this.pollingInterval = pollingInterval;

View File

@@ -29,7 +29,7 @@ implements RemovableDriveMonitor.Callback {
RemovableDrivePlugin(Executor ioExecutor, FileUtils fileUtils,
SimplexPluginCallback callback, RemovableDriveFinder finder,
RemovableDriveMonitor monitor, int maxFrameLength, long maxLatency) {
RemovableDriveMonitor monitor, int maxFrameLength, int maxLatency) {
super(ioExecutor, fileUtils, callback, maxFrameLength, maxLatency);
this.finder = finder;
this.monitor = monitor;
@@ -54,7 +54,7 @@ implements RemovableDriveMonitor.Callback {
return false;
}
public long getPollingInterval() {
public int getPollingInterval() {
throw new UnsupportedOperationException();
}

View File

@@ -14,8 +14,8 @@ import org.briarproject.util.OsUtils;
public class RemovableDrivePluginFactory implements SimplexPluginFactory {
// Maximum latency 14 days (Royal Mail or lackadaisical carrier pigeon)
private static final long MAX_LATENCY = 14 * 24 * 60 * 60 * 1000;
private static final long POLLING_INTERVAL = 10 * 1000; // 10 seconds
private static final int MAX_LATENCY = 14 * 24 * 60 * 60 * 1000;
private static final int POLLING_INTERVAL = 10 * 1000; // 10 seconds
private final Executor ioExecutor;
private final FileUtils fileUtils;

View File

@@ -32,21 +32,18 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
private final ModemFactory modemFactory;
private final SerialPortList serialPortList;
private final DuplexPluginCallback callback;
private final int maxFrameLength;
private final long maxLatency, pollingInterval;
private final int maxFrameLength, maxLatency;
private volatile boolean running = false;
private volatile Modem modem = null;
ModemPlugin(ModemFactory modemFactory, SerialPortList serialPortList,
DuplexPluginCallback callback, int maxFrameLength, long maxLatency,
long pollingInterval) {
DuplexPluginCallback callback, int maxFrameLength, int maxLatency) {
this.modemFactory = modemFactory;
this.serialPortList = serialPortList;
this.callback = callback;
this.maxFrameLength = maxFrameLength;
this.maxLatency = maxLatency;
this.pollingInterval = pollingInterval;
}
public TransportId getId() {
@@ -57,13 +54,13 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
return maxFrameLength;
}
public long getMaxLatency() {
public int getMaxLatency() {
return maxLatency;
}
public long getMaxIdleTime() {
public int getMaxIdleTime() {
// FIXME: Do we need keepalives for this transport?
return Long.MAX_VALUE;
return Integer.MAX_VALUE;
}
public boolean start() {
@@ -103,8 +100,8 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
return false;
}
public long getPollingInterval() {
return pollingInterval;
public int getPollingInterval() {
throw new UnsupportedOperationException();
}
public void poll(Collection<ContactId> connected) {
@@ -226,11 +223,11 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
return getMaxFrameLength();
}
public long getMaxLatency() {
public int getMaxLatency() {
return getMaxLatency();
}
public long getMaxIdleTime() {
public int getMaxIdleTime() {
return getMaxIdleTime();
}

View File

@@ -12,8 +12,7 @@ import org.briarproject.util.StringUtils;
public class ModemPluginFactory implements DuplexPluginFactory {
private static final int MAX_FRAME_LENGTH = 1024;
private static final long MAX_LATENCY = 60 * 1000; // 1 minute
private static final long POLLING_INTERVAL = 60 * 60 * 1000; // 1 hour
private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
private final ModemFactory modemFactory;
private final SerialPortList serialPortList;
@@ -33,6 +32,6 @@ public class ModemPluginFactory implements DuplexPluginFactory {
String enabled = callback.getConfig().get("enabled");
if(StringUtils.isNullOrEmpty(enabled)) return null;
return new ModemPlugin(modemFactory, serialPortList, callback,
MAX_FRAME_LENGTH, MAX_LATENCY, POLLING_INTERVAL);
MAX_FRAME_LENGTH, MAX_LATENCY);
}
}