forked from I2P_Developers/i2p.i2p
I2PTunnel: Fix a shared client configured with i2cp.newDestOnResume
not restarting correctly, caused by previous checkin
This commit is contained in:
@@ -252,7 +252,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
protected void verifySocketManager() {
|
protected void verifySocketManager() {
|
||||||
synchronized(sockLock) {
|
synchronized(sockLock) {
|
||||||
boolean newManager = false;
|
boolean newManager = false;
|
||||||
if (this.sockMgr == null) {
|
// other shared client could have destroyed it
|
||||||
|
if (this.sockMgr == null || this.sockMgr.isDestroyed()) {
|
||||||
newManager = true;
|
newManager = true;
|
||||||
} else {
|
} else {
|
||||||
I2PSession sess = sockMgr.getSession();
|
I2PSession sess = sockMgr.getSession();
|
||||||
@@ -264,7 +265,14 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn(getTunnel().getClientOptions().getProperty("inbound.nickname") + ": Built a new destination on resume");
|
_log.warn(getTunnel().getClientOptions().getProperty("inbound.nickname") + ": Built a new destination on resume");
|
||||||
// make sure the old one is closed
|
// make sure the old one is closed
|
||||||
sockMgr.destroySocketManager();
|
// if it's shared client, it will be destroyed in getSocketManager()
|
||||||
|
// with the correct locking
|
||||||
|
boolean shouldDestroy;
|
||||||
|
synchronized(I2PTunnelClientBase.class) {
|
||||||
|
shouldDestroy = sockMgr != socketManager;
|
||||||
|
}
|
||||||
|
if (shouldDestroy)
|
||||||
|
sockMgr.destroySocketManager();
|
||||||
newManager = true;
|
newManager = true;
|
||||||
} // else the old socket manager will reconnect the old session if necessary
|
} // else the old socket manager will reconnect the old session if necessary
|
||||||
}
|
}
|
||||||
@@ -316,7 +324,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
protected static synchronized I2PSocketManager getSocketManager(I2PTunnel tunnel, String pkf) {
|
protected static synchronized I2PSocketManager getSocketManager(I2PTunnel tunnel, String pkf) {
|
||||||
// shadows instance _log
|
// shadows instance _log
|
||||||
Log _log = tunnel.getContext().logManager().getLog(I2PTunnelClientBase.class);
|
Log _log = tunnel.getContext().logManager().getLog(I2PTunnelClientBase.class);
|
||||||
if (socketManager != null) {
|
if (socketManager != null && !socketManager.isDestroyed()) {
|
||||||
I2PSession s = socketManager.getSession();
|
I2PSession s = socketManager.getSession();
|
||||||
if (s.isClosed()) {
|
if (s.isClosed()) {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
|
@@ -104,9 +104,17 @@ public interface I2PSocketManager {
|
|||||||
* Destroy the socket manager, freeing all the associated resources. This
|
* Destroy the socket manager, freeing all the associated resources. This
|
||||||
* method will block untill all the managed sockets are closed.
|
* method will block untill all the managed sockets are closed.
|
||||||
*
|
*
|
||||||
|
* The socket manager CANNOT be reused after this.
|
||||||
*/
|
*/
|
||||||
public void destroySocketManager();
|
public void destroySocketManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has the socket manager been destroyed?
|
||||||
|
*
|
||||||
|
* @since 0.9.9
|
||||||
|
*/
|
||||||
|
public boolean isDestroyed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
|
* Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
|
||||||
*
|
*
|
||||||
|
@@ -338,6 +338,15 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Has the socket manager been destroyed?
|
||||||
|
*
|
||||||
|
* @since 0.9.9
|
||||||
|
*/
|
||||||
|
public boolean isDestroyed() {
|
||||||
|
return _isDestroyed.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
|
* Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
|
||||||
*
|
*
|
||||||
|
@@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 31;
|
public final static long BUILD = 32;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "-rc";
|
public final static String EXTRA = "-rc";
|
||||||
|
Reference in New Issue
Block a user