* Streaming lib: Plug timer leak, don't send keepalives
after close, don't disconnect hard after close
This commit is contained in:
@ -839,6 +839,8 @@ public class Connection {
|
|||||||
setFuzz(5*1000); // sloppy timer, don't reschedule unless at least 5s later
|
setFuzz(5*1000); // sloppy timer, don't reschedule unless at least 5s later
|
||||||
}
|
}
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug("Fire inactivity timer on " + Connection.this.toString());
|
||||||
// uh, nothing more to do...
|
// uh, nothing more to do...
|
||||||
if (!_connected) {
|
if (!_connected) {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Inactivity timeout reached, but we are already closed");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("Inactivity timeout reached, but we are already closed");
|
||||||
@ -864,6 +866,9 @@ public class Connection {
|
|||||||
// if one of us can't talk...
|
// if one of us can't talk...
|
||||||
// No - not true - data and acks are still going back and forth.
|
// No - not true - data and acks are still going back and forth.
|
||||||
// Prevent zombie connections by keeping the inactivity timer.
|
// Prevent zombie connections by keeping the inactivity timer.
|
||||||
|
// Not sure why... receiving a close but never sending one?
|
||||||
|
// If so we can probably re-enable this for _closeSentOn.
|
||||||
|
// For further investigation...
|
||||||
//if ( (_closeSentOn > 0) || (_closeReceivedOn > 0) ) {
|
//if ( (_closeSentOn > 0) || (_closeReceivedOn > 0) ) {
|
||||||
// if (_log.shouldLog(Log.DEBUG)) _log.debug("Inactivity timeout reached, but we are closing");
|
// if (_log.shouldLog(Log.DEBUG)) _log.debug("Inactivity timeout reached, but we are closing");
|
||||||
// return;
|
// return;
|
||||||
@ -873,15 +878,17 @@ public class Connection {
|
|||||||
|
|
||||||
// bugger it, might as well do the hard work now
|
// bugger it, might as well do the hard work now
|
||||||
switch (_options.getInactivityAction()) {
|
switch (_options.getInactivityAction()) {
|
||||||
case ConnectionOptions.INACTIVITY_ACTION_SEND:
|
|
||||||
if (_log.shouldLog(Log.WARN))
|
|
||||||
_log.warn("Sending some data due to inactivity");
|
|
||||||
_receiver.send(null, 0, 0, true);
|
|
||||||
break;
|
|
||||||
case ConnectionOptions.INACTIVITY_ACTION_NOOP:
|
case ConnectionOptions.INACTIVITY_ACTION_NOOP:
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Inactivity timer expired, but we aint doin' shit");
|
_log.warn("Inactivity timer expired, but we aint doin' shit");
|
||||||
break;
|
break;
|
||||||
|
case ConnectionOptions.INACTIVITY_ACTION_SEND:
|
||||||
|
if (_closeSentOn <= 0 && _closeReceivedOn <= 0) {
|
||||||
|
if (_log.shouldLog(Log.WARN))
|
||||||
|
_log.warn("Sending some data due to inactivity");
|
||||||
|
_receiver.send(null, 0, 0, true);
|
||||||
|
break;
|
||||||
|
} // else fall through
|
||||||
case ConnectionOptions.INACTIVITY_ACTION_DISCONNECT:
|
case ConnectionOptions.INACTIVITY_ACTION_DISCONNECT:
|
||||||
// fall through
|
// fall through
|
||||||
default:
|
default:
|
||||||
@ -897,7 +904,9 @@ public class Connection {
|
|||||||
|
|
||||||
_inputStream.streamErrorOccurred(new IOException("Inactivity timeout"));
|
_inputStream.streamErrorOccurred(new IOException("Inactivity timeout"));
|
||||||
_outputStream.streamErrorOccurred(new IOException("Inactivity timeout"));
|
_outputStream.streamErrorOccurred(new IOException("Inactivity timeout"));
|
||||||
disconnect(false);
|
// Clean disconnect if we have already scheduled one
|
||||||
|
// (generally because we already sent a close)
|
||||||
|
disconnect(_disconnectScheduledOn >= 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1046,7 +1055,9 @@ public class Connection {
|
|||||||
if (_packet.getAckTime() > 0)
|
if (_packet.getAckTime() > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_resetSent || _resetReceived) {
|
if (_resetSent || _resetReceived || !_connected) {
|
||||||
|
if(_log.shouldLog(Log.WARN) && (!_resetSent) && (!_resetReceived))
|
||||||
|
_log.warn("??? no resets but not connected: " + _packet); // don't think this is possible
|
||||||
_packet.cancelled();
|
_packet.cancelled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,8 @@ class ConnectionHandler {
|
|||||||
if (!_active) {
|
if (!_active) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Dropping new SYN request, as we're not listening");
|
_log.warn("Dropping new SYN request, as we're not listening");
|
||||||
sendReset(packet);
|
if (packet.isFlagSet(Packet.FLAG_SYNCHRONIZE))
|
||||||
|
sendReset(packet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
@ -41,6 +41,8 @@ import net.i2p.util.Log;
|
|||||||
* <li>{@link #FLAG_DELAY_REQUESTED}: 2 byte integer</li>
|
* <li>{@link #FLAG_DELAY_REQUESTED}: 2 byte integer</li>
|
||||||
* <li>{@link #FLAG_MAX_PACKET_SIZE_INCLUDED}: 2 byte integer</li>
|
* <li>{@link #FLAG_MAX_PACKET_SIZE_INCLUDED}: 2 byte integer</li>
|
||||||
* <li>{@link #FLAG_PROFILE_INTERACTIVE}: no option data</li>
|
* <li>{@link #FLAG_PROFILE_INTERACTIVE}: no option data</li>
|
||||||
|
* <li>{@link #FLAG_ECHO}: no option data</li>
|
||||||
|
* <li>{@link #FLAG_NO_ACK}: no option data</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* <p>If the signature is included, it uses the Destination's DSA key
|
* <p>If the signature is included, it uses the Destination's DSA key
|
||||||
|
Reference in New Issue
Block a user