forked from I2P_Developers/i2p.i2p
I2CP Multisession - Work in progress:
Start availability notifier in subsession Availability notifier cleanup Various log tweaks added while chasing this down Better subsession state management I2PSocketManagerFull verifies subsession to force connect() Successfully tested
This commit is contained in:
@@ -891,4 +891,12 @@ class ConnectionManager {
|
||||
if (req != null)
|
||||
req.pong(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.20
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConnectionManager for " + _session;
|
||||
}
|
||||
}
|
||||
|
@@ -388,11 +388,16 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
}
|
||||
|
||||
private void verifySession() throws I2PException {
|
||||
verifySession(_connectionManager);
|
||||
}
|
||||
|
||||
/** @since 0.9.20 */
|
||||
private void verifySession(ConnectionManager cm) throws I2PException {
|
||||
if (_isDestroyed.get())
|
||||
throw new I2PException("Session was closed");
|
||||
if (!_connectionManager.getSession().isClosed())
|
||||
if (!cm.getSession().isClosed())
|
||||
return;
|
||||
_connectionManager.getSession().connect();
|
||||
cm.getSession().connect();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +416,6 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
*/
|
||||
public I2PSocket connect(Destination peer, I2PSocketOptions options)
|
||||
throws I2PException, NoRouteToHostException {
|
||||
verifySession();
|
||||
if (options == null)
|
||||
options = _defaultOptions;
|
||||
ConnectionOptions opts = null;
|
||||
@@ -437,6 +441,7 @@ public class I2PSocketManagerFull implements I2PSocketManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
verifySession(cm);
|
||||
// the following blocks unless connect delay > 0
|
||||
Connection con = cm.connect(peer, opts);
|
||||
if (con == null)
|
||||
|
@@ -50,7 +50,7 @@ class MessageHandler implements I2PSessionMuxedListener {
|
||||
* @param size size of the message
|
||||
*/
|
||||
public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort) {
|
||||
byte data[] = null;
|
||||
byte data[];
|
||||
try {
|
||||
data = session.receiveMessage(msgId);
|
||||
} catch (I2PSessionException ise) {
|
||||
@@ -59,7 +59,17 @@ class MessageHandler implements I2PSessionMuxedListener {
|
||||
_log.warn("Error receiving the message", ise);
|
||||
return;
|
||||
}
|
||||
if (data == null) return;
|
||||
if (data == null) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Received null data on " + session + " proto: " + proto +
|
||||
" fromPort: " + fromPort + " toPort: " + toPort);
|
||||
return;
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Received " + data.length + " bytes on " + session +
|
||||
" (" + _manager + ')' +
|
||||
" proto: " + proto +
|
||||
" fromPort: " + fromPort + " toPort: " + toPort);
|
||||
Packet packet = new Packet();
|
||||
try {
|
||||
packet.readPacket(data, 0, data.length);
|
||||
|
@@ -498,6 +498,27 @@ class MessageInputStream extends InputStream {
|
||||
@Override
|
||||
public void close() {
|
||||
synchronized (_dataLock) {
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
StringBuilder buf = new StringBuilder(128);
|
||||
buf.append("close(), ready bytes: ");
|
||||
long available = 0;
|
||||
for (int i = 0; i < _readyDataBlocks.size(); i++)
|
||||
available += _readyDataBlocks.get(i).getValid();
|
||||
available -= _readyDataBlockIndex;
|
||||
buf.append(available);
|
||||
buf.append(" blocks: ").append(_readyDataBlocks.size());
|
||||
buf.append(" not ready blocks: ");
|
||||
long notAvailable = 0;
|
||||
for (Long id : _notYetReadyBlocks.keySet()) {
|
||||
ByteArray ba = _notYetReadyBlocks.get(id);
|
||||
buf.append(id).append(" ");
|
||||
if (ba != null)
|
||||
notAvailable += ba.getValid();
|
||||
}
|
||||
buf.append("not ready bytes: ").append(notAvailable);
|
||||
buf.append(" highest ready block: ").append(_highestReadyBlockId);
|
||||
_log.debug(buf.toString());
|
||||
}
|
||||
//while (_readyDataBlocks.size() > 0)
|
||||
// _cache.release((ByteArray)_readyDataBlocks.remove(0));
|
||||
_readyDataBlocks.clear();
|
||||
|
Reference in New Issue
Block a user