2005-12-30 jrandom

* Close streams more gracefully
This commit is contained in:
jrandom
2005-12-30 23:33:52 +00:00
committed by zzz
parent 8e87ae08fb
commit 0f8611e465
12 changed files with 52 additions and 25 deletions

View File

@ -211,14 +211,20 @@ public class Connection {
if (evt != null) {
boolean sent = evt.retransmit(false);
if (sent) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Retransmitting " + packet + " as an ack");
return;
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Not retransmitting " + packet + " as an ack");
//SimpleTimer.getInstance().addEvent(evt, evt.getNextSendTime());
}
}
}
// if we don't have anything to retransmit, send a small ack
packet = _receiver.send(null, 0, 0);
if (_log.shouldLog(Log.DEBUG))
_log.debug("sending new ack: " + packet);
//packet.releasePayload();
}
@ -286,6 +292,8 @@ public class Connection {
if (packet.isFlagSet(Packet.FLAG_CLOSE) || (remaining < 2)) {
packet.setOptionalDelay(0);
packet.setFlag(Packet.FLAG_DELAY_REQUESTED);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Requesting no ack delay for packet " + packet);
} else {
int delay = _options.getRTO() / 2;
packet.setOptionalDelay(delay);
@ -1031,10 +1039,9 @@ public class Connection {
+ newWindowSize + " lifetime "
+ (_context.clock().now() - _packet.getCreatedOn()) + "ms)");
_outboundQueue.enqueue(_packet);
_lastSendTime = _context.clock().now();
}
_lastSendTime = _context.clock().now();
// acked during resending (... or somethin')
if ( (_packet.getAckTime() > 0) && (_packet.getNumSends() > 1) ) {
_activeResends--;

View File

@ -184,8 +184,8 @@ class ConnectionDataReceiver implements MessageOutputStream.DataReceiver {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Closed is set for a new packet on " + con + ": " + packet);
} else {
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("Closed is not set for a new packet on " + _connection + ": " + packet);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Closed is not set for a new packet on " + _connection + ": " + packet);
}
return packet;
}
@ -202,6 +202,6 @@ class ConnectionDataReceiver implements MessageOutputStream.DataReceiver {
}
void destroy() {
_connection = null;
//_connection = null;
}
}

View File

@ -183,10 +183,14 @@ public class ConnectionPacketHandler {
// we've already scheduled an ack above, so there is no need to schedule
// a fast ack (we can wait a few ms)
} else {
if (con.getLastSendTime() + 2000 < _context.clock().now()) {
long timeSinceSend = _context.clock().now() - con.getLastSendTime();
if (timeSinceSend >= 2000) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Fast ack for dup " + packet);
con.ackImmediately();
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Not fast acking dup " + packet + " since we last sent " + timeSinceSend + "ms ago");
}
}
}
@ -440,7 +444,8 @@ public class ConnectionPacketHandler {
}
public void timeReached() {
if (_con.getLastSendTime() <= _created) {
if (!_con.getIsConnected()) return;
if (_con.getResetReceived() || _con.getResetSent() || (_con.getUnackedPacketsReceived() <= 0) )
return;
if (_log.shouldLog(Log.DEBUG))
_log.debug("Last sent was a while ago, and we want to ack a dup");