From 9690a89a6d7b5c249cc612aa1521afdf32f7f16a Mon Sep 17 00:00:00 2001 From: jrandom <jrandom> Date: Wed, 23 Jun 2004 19:48:25 +0000 Subject: [PATCH] sliices are only too slow if there's something pending logging mods i really need to rewrite the tcp transport - the code is all functional, but the design sucks. with the FIFO bandwidth limiter we could get away with a single 'send' thread rather than each TCPConnection having its own writer thread (but we'd still need the per-con reader thread, at least until nio is solid enough) but maybe the rewrite can hold off until the AMOC implementation. we'll see --- .../net/i2p/router/transport/tcp/TCPConnection.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java b/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java index fd31adc329..a2b1209da1 100644 --- a/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java +++ b/router/java/src/net/i2p/router/transport/tcp/TCPConnection.java @@ -423,7 +423,15 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { */ private boolean slicesTooLong() { if (_lastSliceRun <= 0) return false; + synchronized (_toBeSent) { + // if there's nothing pending, dont worry about it + if (_toBeSent.size() <= 0) + return false; + } long diff = _context.clock().now() - _lastSliceRun; + boolean tooLong = diff > MAX_SLICE_DURATION; + if (tooLong) + _log.warn("Slices are taking " + diff + "ms"); return (diff > MAX_SLICE_DURATION); } @@ -542,7 +550,7 @@ class TCPConnection implements I2NPMessageReader.I2NPMessageEventListener { + " bytes in " + (end - afterExpire) + "ms (write took " + (end - beforeWrite) + "ms, prepare took " + (beforeWrite - afterExpire) + "ms)"); - if (timeLeft < 10*1000) { + if (timeLeft < 2*1000) { if (_log.shouldLog(Log.DEBUG)) _log.warn("Very little time left... time to send [" + (end-start) + "] time left [" + timeLeft + "] to " -- GitLab