I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 1ab55368 authored by jrandom's avatar jrandom Committed by zzz
Browse files

la la la

(yeah, this is what broke cvs HEAD, causing transmission failures, disconnects, encryption errors, etc.  oops)
parent 9690a89a
No related branches found
No related tags found
No related merge requests found
...@@ -37,21 +37,16 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream { ...@@ -37,21 +37,16 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
out.write(val); out.write(val);
} }
public void write(byte src[]) throws IOException { public void write(byte src[]) throws IOException {
if (src == null) return; write(src, 0, src.length);
if (src.length > CHUNK_SIZE) {
for (int i = 0; i < src.length; ) {
write(src, i*CHUNK_SIZE, CHUNK_SIZE);
i += CHUNK_SIZE;
}
} else {
write(src, 0, src.length);
}
} }
public void write(byte src[], int off, int len) throws IOException { public void write(byte src[], int off, int len) throws IOException {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Writing " + len + " bytes"); _log.debug("Writing " + len + " bytes");
if (src == null) return; if (src == null) return;
if (len <= 0) return; if (len <= 0) return;
if (len + off > src.length)
throw new IllegalArgumentException("wtf are you thinking? len=" + len
+ ", off=" + off + ", data=" + src.length);
if (len <= CHUNK_SIZE) { if (len <= CHUNK_SIZE) {
_context.bandwidthLimiter().delayOutbound(_peer, len); _context.bandwidthLimiter().delayOutbound(_peer, len);
out.write(src, off, len); out.write(src, off, len);
...@@ -62,10 +57,10 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream { ...@@ -62,10 +57,10 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
out.write(src, off+i, CHUNK_SIZE); out.write(src, off+i, CHUNK_SIZE);
i += CHUNK_SIZE; i += CHUNK_SIZE;
} }
int remainder = len % CHUNK_SIZE; int remainder = (len % CHUNK_SIZE);
if (remainder != 0) { if (remainder > 0) {
_context.bandwidthLimiter().delayOutbound(_peer, remainder); _context.bandwidthLimiter().delayOutbound(_peer, remainder);
out.write(src, off+len-(remainder), remainder); out.write(src, i, remainder);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment