2004-12-08 jrandom

* Revised the buffering when reading from the SAM client and writing
      to the stream.  Also added a thread (sigh) so we don't block the
      SAM client from giving us more messages for abnormally long periods
      of time.
    * Display the router version in the logs on startup (oft requested)
    * Fix a race during the closing of a messageOutputStream
This commit is contained in:
jrandom
2004-12-08 17:16:16 +00:00
committed by zzz
parent 4c5f7b9451
commit d88396c1e2
8 changed files with 183 additions and 93 deletions

View File

@ -394,15 +394,12 @@ public class Connection {
if (_socket != null)
_socket.destroy();
_socket = null;
_inputStream = null;
if (_outputStream != null)
_outputStream.destroy();
_outputStream = null;
_outboundQueue = null;
if (_receiver != null)
_receiver.destroy();
if (_activityTimer != null)
SimpleTimer.getInstance().addEvent(_activityTimer, 1);
SimpleTimer.getInstance().removeEvent(_activityTimer);
_activityTimer = null;
if (!_disconnectScheduled) {

View File

@ -155,12 +155,13 @@ public class MessageOutputStream extends OutputStream {
}
public void timeReached() {
_enqueued = false;
DataReceiver rec = _dataReceiver;
long timeLeft = (_lastBuffered + _passiveFlushDelay - _context.clock().now());
if (_log.shouldLog(Log.DEBUG))
_log.debug("flusher time reached: left = " + timeLeft);
if (timeLeft > 0)
enqueue();
else if (_dataReceiver.writeInProcess())
else if ( (rec != null) && (rec.writeInProcess()) )
enqueue(); // don't passive flush if there is a write being done (unacked outbound)
else
doFlush();