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

@@ -28,8 +28,7 @@ public abstract class FilePlugin implements SimplexPlugin {
protected final Executor ioExecutor;
protected final FileUtils fileUtils;
protected final SimplexPluginCallback callback;
protected final int maxFrameLength;
protected final long maxLatency;
protected final int maxFrameLength, maxLatency;
protected volatile boolean running = false;
@@ -40,7 +39,7 @@ public abstract class FilePlugin implements SimplexPlugin {
protected FilePlugin(Executor ioExecutor, FileUtils fileUtils,
SimplexPluginCallback callback, int maxFrameLength,
long maxLatency) {
int maxLatency) {
this.ioExecutor = ioExecutor;
this.fileUtils = fileUtils;
this.callback = callback;
@@ -52,12 +51,12 @@ public abstract class FilePlugin implements SimplexPlugin {
return maxFrameLength;
}
public long getMaxLatency() {
public int getMaxLatency() {
return maxLatency;
}
public long getMaxIdleTime() {
return Long.MAX_VALUE; // We don't need keepalives
public int getMaxIdleTime() {
return Integer.MAX_VALUE; // We don't need keepalives
}
public boolean isRunning() {

View File

@@ -31,11 +31,11 @@ class FileTransportWriter implements TransportConnectionWriter {
return plugin.getMaxFrameLength();
}
public long getMaxLatency() {
public int getMaxLatency() {
return plugin.getMaxLatency();
}
public long getMaxIdleTime() {
public int getMaxIdleTime() {
return plugin.getMaxIdleTime();
}

View File

@@ -17,8 +17,8 @@ class LanTcpPlugin extends TcpPlugin {
static final TransportId ID = new TransportId("lan");
LanTcpPlugin(Executor ioExecutor, DuplexPluginCallback callback,
int maxFrameLength, long maxLatency, long maxIdleTime,
long pollingInterval) {
int maxFrameLength, int maxLatency, int maxIdleTime,
int pollingInterval) {
super(ioExecutor, callback, maxFrameLength, maxLatency, maxIdleTime,
pollingInterval);
}

View File

@@ -10,9 +10,9 @@ import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
public class LanTcpPluginFactory implements DuplexPluginFactory {
private static final int MAX_FRAME_LENGTH = 1024;
private static final long MAX_LATENCY = 60 * 1000; // 1 minute
private static final long MAX_IDLE_TIME = 30 * 1000; // 30 seconds
private static final long POLLING_INTERVAL = 60 * 1000; // 1 minute
private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
private static final int MAX_IDLE_TIME = 30 * 1000; // 30 seconds
private static final int POLLING_INTERVAL = 3 * 60 * 1000; // 3 minutes
private final Executor ioExecutor;

View File

@@ -37,8 +37,8 @@ abstract class TcpPlugin implements DuplexPlugin {
protected final Executor ioExecutor;
protected final DuplexPluginCallback callback;
protected final int maxFrameLength, socketTimeout;
protected final long maxLatency, maxIdleTime, pollingInterval;
protected final int maxFrameLength, maxLatency, maxIdleTime;
protected final int pollingInterval, socketTimeout;
protected volatile boolean running = false;
protected volatile ServerSocket socket = null;
@@ -53,28 +53,28 @@ abstract class TcpPlugin implements DuplexPlugin {
protected abstract boolean isConnectable(InetSocketAddress remote);
protected TcpPlugin(Executor ioExecutor, DuplexPluginCallback callback,
int maxFrameLength, long maxLatency, long maxIdleTime,
long pollingInterval) {
int maxFrameLength, int maxLatency, int maxIdleTime,
int pollingInterval) {
this.ioExecutor = ioExecutor;
this.callback = callback;
this.maxFrameLength = maxFrameLength;
this.maxLatency = maxLatency;
this.maxIdleTime = maxIdleTime;
this.pollingInterval = pollingInterval;
if(2 * maxIdleTime > Integer.MAX_VALUE)
if(maxIdleTime > Integer.MAX_VALUE / 2)
socketTimeout = Integer.MAX_VALUE;
else socketTimeout = (int) (2 * maxIdleTime);
else socketTimeout = maxIdleTime * 2;
}
public int getMaxFrameLength() {
return maxFrameLength;
}
public long getMaxLatency() {
public int getMaxLatency() {
return maxLatency;
}
public long getMaxIdleTime() {
public int getMaxIdleTime() {
return maxIdleTime;
}
@@ -171,7 +171,7 @@ abstract class TcpPlugin implements DuplexPlugin {
return true;
}
public long getPollingInterval() {
public int getPollingInterval() {
return pollingInterval;
}

View File

@@ -63,11 +63,11 @@ class TcpTransportConnection 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

@@ -20,9 +20,9 @@ class WanTcpPlugin extends TcpPlugin {
private volatile MappingResult mappingResult;
WanTcpPlugin(Executor ioExecutor, DuplexPluginCallback callback,
int maxFrameLength, long maxLatency, long maxIdleTime,
long pollingInterval, PortMapper portMapper) {
WanTcpPlugin(Executor ioExecutor, PortMapper portMapper,
DuplexPluginCallback callback, int maxFrameLength, int maxLatency,
int maxIdleTime, int pollingInterval) {
super(ioExecutor, callback, maxFrameLength, maxLatency, maxIdleTime,
pollingInterval);
this.portMapper = portMapper;

View File

@@ -11,9 +11,9 @@ import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
public class WanTcpPluginFactory implements DuplexPluginFactory {
private static final int MAX_FRAME_LENGTH = 1024;
private static final long MAX_LATENCY = 60 * 1000; // 1 minute
private static final long MAX_IDLE_TIME = 30 * 1000; // 30 seconds
private static final long POLLING_INTERVAL = 5 * 60 * 1000; // 5 minutes
private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
private static final int MAX_IDLE_TIME = 30 * 1000; // 30 seconds
private static final int POLLING_INTERVAL = 5 * 60 * 1000; // 5 minutes
private final Executor ioExecutor;
private final ShutdownManager shutdownManager;
@@ -29,8 +29,8 @@ public class WanTcpPluginFactory implements DuplexPluginFactory {
}
public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
return new WanTcpPlugin(ioExecutor, callback, MAX_FRAME_LENGTH,
MAX_LATENCY, MAX_IDLE_TIME, POLLING_INTERVAL,
new PortMapperImpl(shutdownManager));
return new WanTcpPlugin(ioExecutor, new PortMapperImpl(shutdownManager),
callback, MAX_FRAME_LENGTH, MAX_LATENCY, MAX_IDLE_TIME,
POLLING_INTERVAL);
}
}