in provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java [602:633]
public int write(ByteBuffer src) throws IOException {
if( max_write_rate==0 ) {
return channel.write(src);
} else {
int remaining = src.remaining();
if( write_allowance ==0 || remaining ==0 ) {
return 0;
}
int reduction = 0;
if( remaining > write_allowance) {
reduction = remaining - write_allowance;
src.limit(src.limit() - reduction);
}
int rc;
try {
rc = channel.write(src);
write_allowance -= rc;
} finally {
if( reduction!=0 ) {
if( src.remaining() == 0 ) {
// we need to suspend the read now until we get
// a new allowance...
write_suspended = true;
suspendWrite();
}
src.limit(src.limit() + reduction);
}
}
return rc;
}
}