From c73f3385c07ba8f7c1040068e2aa9b9957bf01b3 Mon Sep 17 00:00:00 2001 From: jrandom <jrandom> Date: Thu, 26 Aug 2004 17:59:47 +0000 Subject: [PATCH] don't ask the bandwidth limiter to authorize reading an EOF ;) (this fixes the longstanding "-318 bytes read" bug) --- .../net/i2p/router/transport/BandwidthLimitedInputStream.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/router/java/src/net/i2p/router/transport/BandwidthLimitedInputStream.java b/router/java/src/net/i2p/router/transport/BandwidthLimitedInputStream.java index 0464386bf8..ffd0410191 100644 --- a/router/java/src/net/i2p/router/transport/BandwidthLimitedInputStream.java +++ b/router/java/src/net/i2p/router/transport/BandwidthLimitedInputStream.java @@ -62,6 +62,8 @@ public class BandwidthLimitedInputStream extends FilterInputStream { public int read(byte dest[], int off, int len) throws IOException { int read = in.read(dest, off, len); + if (read == -1) return -1; + if (_pullFromOutbound) _currentRequest = _context.bandwidthLimiter().requestOutbound(read, _peerSource); else @@ -84,6 +86,7 @@ public class BandwidthLimitedInputStream extends FilterInputStream { } public long skip(long numBytes) throws IOException { long skip = in.skip(numBytes); + if (_pullFromOutbound) _currentRequest = _context.bandwidthLimiter().requestOutbound((int)skip, _peerSource); else -- GitLab