Streaming: Fix race NPE (thx echelon)

This commit is contained in:
zzz
2012-02-20 19:34:13 +00:00
parent a15e4c6c28
commit ad8ce95545
4 changed files with 20 additions and 6 deletions

View File

@ -548,9 +548,11 @@ class Connection {
void disconnectComplete() { void disconnectComplete() {
_connected = false; _connected = false;
if (_socket != null) I2PSocketFull s = _socket;
_socket.destroy(); if (s != null) {
_socket = null; s.destroy2();
_socket = null;
}
if (_outputStream != null) if (_outputStream != null)
_outputStream.destroy(); _outputStream.destroy();
if (_receiver != null) if (_receiver != null)

View File

@ -131,12 +131,21 @@ class I2PSocketFull implements I2PSocket {
void destroy() { void destroy() {
Connection c = _connection; Connection c = _connection;
_connection = null; destroy2();
_listener = null;
if (c != null) if (c != null)
c.disconnectComplete(); c.disconnectComplete();
} }
/**
* Call from Connection.disconnectComplete()
* instead of destroy() so we don't loop
* @since 0.8.13
*/
void destroy2() {
_connection = null;
_listener = null;
}
/** /**
* The remote port. * The remote port.
* @return the port or 0 if unknown * @return the port or 0 if unknown

View File

@ -1,3 +1,6 @@
2012-02-20 zzz
* Streaming: Fix race NPE (thx echelon)
2012-02-17 zzz 2012-02-17 zzz
* i2psnark: Escape fixes * i2psnark: Escape fixes
* netdb.jsp: Fix debug median calculation * netdb.jsp: Fix debug median calculation

View File

@ -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 = 14; public final static long BUILD = 15;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = "-rc"; public final static String EXTRA = "-rc";