use a bandwidth limited stream instead of asking for the allocation of the entire buffer at once (since, uh, its not likely that the bandwidth limiter will ever have hundreds of KBytes available for use)
This commit is contained in:
@ -8,6 +8,8 @@ import net.i2p.util.HTTPSendData;
|
|||||||
import net.i2p.util.I2PThread;
|
import net.i2p.util.I2PThread;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
|
import net.i2p.router.transport.BandwidthLimitedInputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Job that, if its allowed to, will submit the data gathered by the MessageHistory
|
* Job that, if its allowed to, will submit the data gathered by the MessageHistory
|
||||||
* component to some URL so that the network can be debugged more easily. By default
|
* component to some URL so that the network can be debugged more easily. By default
|
||||||
@ -87,8 +89,8 @@ public class SubmitMessageHistoryJob extends JobImpl {
|
|||||||
if (size > 0)
|
if (size > 0)
|
||||||
expectedSend += (int)size/10; // compression
|
expectedSend += (int)size/10; // compression
|
||||||
FileInputStream fin = new FileInputStream(dataFile);
|
FileInputStream fin = new FileInputStream(dataFile);
|
||||||
_context.bandwidthLimiter().delayOutbound(null, expectedSend);
|
BandwidthLimitedInputStream in = new BandwidthLimitedInputStream(_context, fin, null, true);
|
||||||
boolean sent = HTTPSendData.postData(url, size, fin);
|
boolean sent = HTTPSendData.postData(url, size, in);
|
||||||
fin.close();
|
fin.close();
|
||||||
boolean deleted = dataFile.delete();
|
boolean deleted = dataFile.delete();
|
||||||
_log.debug("Submitted " + size + " bytes? " + sent + " and deleted? " + deleted);
|
_log.debug("Submitted " + size + " bytes? " + sent + " and deleted? " + deleted);
|
||||||
|
Reference in New Issue
Block a user