forked from I2P_Developers/i2p.i2p
NTCP: Deadlock fix 3rd try (ticket #1394)
This commit is contained in:
@ -1,3 +1,6 @@
|
|||||||
|
2014-10-17 zzz
|
||||||
|
* NTCP: Deadlock fix 3rd try (ticket #1394)
|
||||||
|
|
||||||
2014-10-16 zzz
|
2014-10-16 zzz
|
||||||
* NTCP: Deadlock fix 2nd try (ticket #1394)
|
* NTCP: Deadlock fix 2nd try (ticket #1394)
|
||||||
|
|
||||||
|
@ -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 = 12;
|
public final static long BUILD = 13;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@ -657,7 +657,7 @@ class EstablishState {
|
|||||||
System.arraycopy(_prevEncrypted, _prevEncrypted.length-AES_SIZE, nextWriteIV, 0, AES_SIZE);
|
System.arraycopy(_prevEncrypted, _prevEncrypted.length-AES_SIZE, nextWriteIV, 0, AES_SIZE);
|
||||||
// this does not copy the nextWriteIV, do not release to cache
|
// this does not copy the nextWriteIV, do not release to cache
|
||||||
_con.finishOutboundEstablishment(_dh.getSessionKey(), (_tsA-_tsB), nextWriteIV, _e_bobSig); // skew in seconds
|
_con.finishOutboundEstablishment(_dh.getSessionKey(), (_tsA-_tsB), nextWriteIV, _e_bobSig); // skew in seconds
|
||||||
releaseBufs();
|
releaseBufs(true);
|
||||||
// if socket gets closed this will be null - prevent NPE
|
// if socket gets closed this will be null - prevent NPE
|
||||||
InetAddress ia = _con.getChannel().socket().getInetAddress();
|
InetAddress ia = _con.getChannel().socket().getInetAddress();
|
||||||
if (ia != null)
|
if (ia != null)
|
||||||
@ -857,7 +857,7 @@ class EstablishState {
|
|||||||
System.arraycopy(_e_bobSig, _e_bobSig.length-AES_SIZE, iv, 0, AES_SIZE);
|
System.arraycopy(_e_bobSig, _e_bobSig.length-AES_SIZE, iv, 0, AES_SIZE);
|
||||||
// this does not copy the IV, do not release to cache
|
// this does not copy the IV, do not release to cache
|
||||||
_con.finishInboundEstablishment(_dh.getSessionKey(), (tsA-_tsB), iv, _prevEncrypted); // skew in seconds
|
_con.finishInboundEstablishment(_dh.getSessionKey(), (tsA-_tsB), iv, _prevEncrypted); // skew in seconds
|
||||||
releaseBufs();
|
releaseBufs(true);
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
_log.info(prefix()+"Verified remote peer as " + _aliceIdent.calculateHash());
|
_log.info(prefix()+"Verified remote peer as " + _aliceIdent.calculateHash());
|
||||||
changeState(State.VERIFIED);
|
changeState(State.VERIFIED);
|
||||||
@ -961,23 +961,21 @@ class EstablishState {
|
|||||||
_e = e;
|
_e = e;
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn(prefix()+"Failed to establish: " + _err, e);
|
_log.warn(prefix()+"Failed to establish: " + _err, e);
|
||||||
releaseBufs();
|
releaseBufs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only call once. Caller must synch.
|
* Only call once. Caller must synch.
|
||||||
* @since 0.9.16
|
* @since 0.9.16
|
||||||
*/
|
*/
|
||||||
private void releaseBufs() {
|
private void releaseBufs(boolean isVerified) {
|
||||||
// null or longer for OB
|
// null or longer for OB
|
||||||
if (_prevEncrypted != null && _prevEncrypted.length == AES_SIZE)
|
if (_prevEncrypted != null && _prevEncrypted.length == AES_SIZE)
|
||||||
SimpleByteCache.release(_prevEncrypted);
|
SimpleByteCache.release(_prevEncrypted);
|
||||||
// Do not release _curEncrypted if verified, it is passed to
|
// Do not release _curEncrypted if verified, it is passed to
|
||||||
// NTCPConnection to use as the IV
|
// NTCPConnection to use as the IV
|
||||||
synchronized(_stateLock) {
|
if (!isVerified)
|
||||||
if (_state != State.VERIFIED)
|
SimpleByteCache.release(_curEncrypted);
|
||||||
SimpleByteCache.release(_curEncrypted);
|
|
||||||
}
|
|
||||||
SimpleByteCache.release(_curDecrypted);
|
SimpleByteCache.release(_curDecrypted);
|
||||||
SimpleByteCache.release(_hX_xor_bobIdentHash);
|
SimpleByteCache.release(_hX_xor_bobIdentHash);
|
||||||
if (_dh.getPeerPublicValue() == null)
|
if (_dh.getPeerPublicValue() == null)
|
||||||
|
Reference in New Issue
Block a user