fix disconnect race NPE

This commit is contained in:
zzz
2010-10-24 16:56:43 +00:00
parent adab0cc3d3
commit 4f9c442d55

View File

@ -190,6 +190,7 @@ public class I2PSnarkUtil {
*/ */
public void disconnect() { public void disconnect() {
I2PSocketManager mgr = _manager; I2PSocketManager mgr = _manager;
// FIXME this can cause race NPEs elsewhere
_manager = null; _manager = null;
_shitlist.clear(); _shitlist.clear();
mgr.destroySocketManager(); mgr.destroySocketManager();
@ -201,6 +202,9 @@ public class I2PSnarkUtil {
/** connect to the given destination */ /** connect to the given destination */
I2PSocket connect(PeerID peer) throws IOException { I2PSocket connect(PeerID peer) throws IOException {
I2PSocketManager mgr = _manager;
if (mgr == null)
throw new IOException("No socket manager");
Destination addr = peer.getAddress(); Destination addr = peer.getAddress();
if (addr == null) if (addr == null)
throw new IOException("Null address"); throw new IOException("Null address");