I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 60aa8c57 authored by zzz's avatar zzz
Browse files

I2PTunnel: Fix a shared client configured with i2cp.newDestOnResume

not restarting correctly, caused by previous checkin
parent 001070f6
No related branches found
No related tags found
No related merge requests found
......@@ -252,7 +252,8 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
protected void verifySocketManager() {
synchronized(sockLock) {
boolean newManager = false;
if (this.sockMgr == null) {
// other shared client could have destroyed it
if (this.sockMgr == null || this.sockMgr.isDestroyed()) {
newManager = true;
} else {
I2PSession sess = sockMgr.getSession();
......@@ -264,7 +265,14 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
if (_log.shouldLog(Log.WARN))
_log.warn(getTunnel().getClientOptions().getProperty("inbound.nickname") + ": Built a new destination on resume");
// 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;
} // 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) {
// shadows instance _log
Log _log = tunnel.getContext().logManager().getLog(I2PTunnelClientBase.class);
if (socketManager != null) {
if (socketManager != null && !socketManager.isDestroyed()) {
I2PSession s = socketManager.getSession();
if (s.isClosed()) {
if (_log.shouldLog(Log.INFO))
......
......@@ -104,8 +104,16 @@ public interface I2PSocketManager {
* Destroy the socket manager, freeing all the associated resources. This
* method will block untill all the managed sockets are closed.
*
* The socket manager CANNOT be reused after this.
*/
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.
......
......@@ -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.
*
......
......@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 31;
public final static long BUILD = 32;
/** for example "-test" */
public final static String EXTRA = "-rc";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment