allow multiple concurrent connections to be created
added a unique ID to more threads
This commit is contained in:
@ -33,6 +33,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
|
|
||||||
private static final long DEFAULT_CONNECT_TIMEOUT = 60 * 1000;
|
private static final long DEFAULT_CONNECT_TIMEOUT = 60 * 1000;
|
||||||
|
|
||||||
|
private static volatile long __clientId = 0;
|
||||||
|
private long _clientId;
|
||||||
protected Object sockLock = new Object(); // Guards sockMgr and mySockets
|
protected Object sockLock = new Object(); // Guards sockMgr and mySockets
|
||||||
private I2PSocketManager sockMgr;
|
private I2PSocketManager sockMgr;
|
||||||
private List mySockets = new ArrayList();
|
private List mySockets = new ArrayList();
|
||||||
@ -60,9 +62,10 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
|
|
||||||
public I2PTunnelClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName) {
|
public I2PTunnelClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName) {
|
||||||
super(localPort + " (uninitialized)", notifyThis);
|
super(localPort + " (uninitialized)", notifyThis);
|
||||||
|
_clientId = ++__clientId;
|
||||||
this.localPort = localPort;
|
this.localPort = localPort;
|
||||||
this.l = l;
|
this.l = l;
|
||||||
this.handlerName = handlerName;
|
this.handlerName = handlerName + _clientId;
|
||||||
|
|
||||||
synchronized (sockLock) {
|
synchronized (sockLock) {
|
||||||
if (ownDest) {
|
if (ownDest) {
|
||||||
@ -75,7 +78,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
l.log("I2P session created");
|
l.log("I2P session created");
|
||||||
|
|
||||||
Thread t = new I2PThread(this);
|
Thread t = new I2PThread(this);
|
||||||
t.setName("Client");
|
t.setName("Client " + _clientId);
|
||||||
listenerReady = false;
|
listenerReady = false;
|
||||||
t.start();
|
t.start();
|
||||||
open = true;
|
open = true;
|
||||||
@ -179,8 +182,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
public I2PSocket createI2PSocket(Destination dest, I2PSocketOptions opt) throws I2PException, ConnectException, NoRouteToHostException, InterruptedIOException {
|
public I2PSocket createI2PSocket(Destination dest, I2PSocketOptions opt) throws I2PException, ConnectException, NoRouteToHostException, InterruptedIOException {
|
||||||
I2PSocket i2ps;
|
I2PSocket i2ps;
|
||||||
|
|
||||||
synchronized (sockLock) {
|
|
||||||
i2ps = sockMgr.connect(dest, opt);
|
i2ps = sockMgr.connect(dest, opt);
|
||||||
|
synchronized (sockLock) {
|
||||||
mySockets.add(i2ps);
|
mySockets.add(i2ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user