* I2PTunnel:
- Try to fix locking to prevent duplicate destinations when using the new option new-dest-on-resume. Still not right for shared clients but should be better for non-shared.
This commit is contained in:
@ -39,7 +39,7 @@ public class I2PTunnelClient extends I2PTunnelClientBase {
|
||||
return;
|
||||
}
|
||||
|
||||
StringTokenizer tok = new StringTokenizer(destinations, ",");
|
||||
StringTokenizer tok = new StringTokenizer(destinations, ", ");
|
||||
dests = new ArrayList(1);
|
||||
while (tok.hasMoreTokens()) {
|
||||
String destination = tok.nextToken();
|
||||
|
@ -345,7 +345,9 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
public I2PSocket createI2PSocket(Destination dest) throws I2PException, ConnectException, NoRouteToHostException, InterruptedIOException {
|
||||
if (sockMgr == null) {
|
||||
// we need this before getDefaultOptions()
|
||||
sockMgr = getSocketManager();
|
||||
synchronized(sockLock) {
|
||||
sockMgr = getSocketManager();
|
||||
}
|
||||
}
|
||||
return createI2PSocket(dest, getDefaultOptions());
|
||||
}
|
||||
@ -369,9 +371,12 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
||||
|
||||
if (sockMgr == null) {
|
||||
// delayed open - call get instead of build because the locking is up there
|
||||
sockMgr = getSocketManager();
|
||||
} else if (Boolean.valueOf(getTunnel().getClientOptions().getProperty("i2cp.newDestOnResume")).booleanValue()) {
|
||||
synchronized(sockMgr) {
|
||||
synchronized(sockLock) {
|
||||
sockMgr = getSocketManager();
|
||||
}
|
||||
} else if (Boolean.valueOf(getTunnel().getClientOptions().getProperty("i2cp.closeOnIdle")).booleanValue() &&
|
||||
Boolean.valueOf(getTunnel().getClientOptions().getProperty("i2cp.newDestOnResume")).booleanValue()) {
|
||||
synchronized(sockLock) {
|
||||
I2PSocketManager oldSockMgr = sockMgr;
|
||||
// This will build a new socket manager and a new dest if the session is closed.
|
||||
sockMgr = getSocketManager();
|
||||
|
@ -211,8 +211,11 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
||||
if (!defaultOpts.contains("i2p.streaming.inactivityTimeout"))
|
||||
defaultOpts.setProperty("i2p.streaming.inactivityTimeout", ""+DEFAULT_READ_TIMEOUT);
|
||||
// delayed start
|
||||
if (sockMgr == null)
|
||||
sockMgr = getSocketManager();
|
||||
if (sockMgr == null) {
|
||||
synchronized(sockLock) {
|
||||
sockMgr = getSocketManager();
|
||||
}
|
||||
}
|
||||
I2PSocketOptions opts = sockMgr.buildOptions(defaultOpts);
|
||||
if (!defaultOpts.containsKey(I2PSocketOptions.PROP_CONNECT_TIMEOUT))
|
||||
opts.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT);
|
||||
|
@ -153,7 +153,9 @@ public class EditBean extends IndexBean {
|
||||
}
|
||||
|
||||
public boolean getNewDest(int tunnel) {
|
||||
return getBooleanProperty(tunnel, "i2cp.newDestOnResume");
|
||||
return getBooleanProperty(tunnel, "i2cp.newDestOnResume") &&
|
||||
getBooleanProperty(tunnel, "i2cp.closeOnIdle") &&
|
||||
!getBooleanProperty(tunnel, "persistentClientKey");
|
||||
}
|
||||
|
||||
public boolean getPersistentClientKey(int tunnel) {
|
||||
|
Reference in New Issue
Block a user