forked from I2P_Developers/i2p.i2p
i2ptunnel: Reduce sleep time in runners to reduce latency
greatly improves "loopback" performance minor cleanups
This commit is contained in:
@@ -99,6 +99,7 @@ public class I2PTunnelOutproxyRunner extends I2PAppThread {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* When was the last data for this runner sent or received?
|
* When was the last data for this runner sent or received?
|
||||||
|
* As of 0.9.20, returns -1 always!
|
||||||
*
|
*
|
||||||
* @return date (ms since the epoch), or -1 if no data has been transferred yet
|
* @return date (ms since the epoch), or -1 if no data has been transferred yet
|
||||||
* @deprecated unused
|
* @deprecated unused
|
||||||
@@ -107,9 +108,11 @@ public class I2PTunnelOutproxyRunner extends I2PAppThread {
|
|||||||
return lastActivityOn;
|
return lastActivityOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
private void updateActivity() {
|
private void updateActivity() {
|
||||||
lastActivityOn = Clock.getInstance().now();
|
lastActivityOn = Clock.getInstance().now();
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When this runner started up transferring data
|
* When this runner started up transferring data
|
||||||
@@ -284,26 +287,31 @@ public class I2PTunnelOutproxyRunner extends I2PAppThread {
|
|||||||
try {
|
try {
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buffer)) != -1) {
|
while ((len = in.read(buffer)) != -1) {
|
||||||
|
if (len > 0) {
|
||||||
out.write(buffer, 0, len);
|
out.write(buffer, 0, len);
|
||||||
if (_toI2P)
|
if (_toI2P)
|
||||||
totalSent += len;
|
totalSent += len;
|
||||||
else
|
else
|
||||||
totalReceived += len;
|
totalReceived += len;
|
||||||
|
//updateActivity();
|
||||||
if (len > 0) updateActivity();
|
}
|
||||||
|
|
||||||
if (in.available() == 0) {
|
if (in.available() == 0) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(direction + ": " + len + " bytes flushed through " + (_toI2P ? "to " : "from ")
|
_log.debug(direction + ": " + len + " bytes flushed through " + (_toI2P ? "to " : "from ")
|
||||||
+ "outproxy");
|
+ "outproxy");
|
||||||
|
if (_toI2P) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(I2PTunnel.PACKET_DELAY);
|
Thread.sleep(5);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in.available() <= 0)
|
if (in.available() <= 0)
|
||||||
out.flush(); // make sure the data get though
|
out.flush();
|
||||||
|
} else {
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//out.flush(); // close() flushes
|
//out.flush(); // close() flushes
|
||||||
|
@@ -198,6 +198,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* When was the last data for this runner sent or received?
|
* When was the last data for this runner sent or received?
|
||||||
|
* As of 0.9.20, returns -1 always!
|
||||||
*
|
*
|
||||||
* @return date (ms since the epoch), or -1 if no data has been transferred yet
|
* @return date (ms since the epoch), or -1 if no data has been transferred yet
|
||||||
* @deprecated unused
|
* @deprecated unused
|
||||||
@@ -206,9 +207,11 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
|||||||
return lastActivityOn;
|
return lastActivityOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****
|
||||||
private void updateActivity() {
|
private void updateActivity() {
|
||||||
lastActivityOn = Clock.getInstance().now();
|
lastActivityOn = Clock.getInstance().now();
|
||||||
}
|
}
|
||||||
|
****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When this runner started up transferring data
|
* When this runner started up transferring data
|
||||||
@@ -448,28 +451,33 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
|||||||
try {
|
try {
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buffer)) != -1) {
|
while ((len = in.read(buffer)) != -1) {
|
||||||
|
if (len > 0) {
|
||||||
out.write(buffer, 0, len);
|
out.write(buffer, 0, len);
|
||||||
if (_toI2P)
|
if (_toI2P)
|
||||||
totalSent += len;
|
totalSent += len;
|
||||||
else
|
else
|
||||||
totalReceived += len;
|
totalReceived += len;
|
||||||
|
//updateActivity();
|
||||||
if (len > 0) updateActivity();
|
}
|
||||||
|
|
||||||
if (in.available() == 0) {
|
if (in.available() == 0) {
|
||||||
//if (_log.shouldLog(Log.DEBUG))
|
//if (_log.shouldLog(Log.DEBUG))
|
||||||
// _log.debug("Flushing after sending " + len + " bytes through");
|
// _log.debug("Flushing after sending " + len + " bytes through");
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(direction + ": " + len + " bytes flushed through " + (_toI2P ? "to " : "from ")
|
_log.debug(direction + ": " + len + " bytes flushed through " + (_toI2P ? "to " : "from ")
|
||||||
+ i2ps.getPeerDestination().calculateHash().toBase64().substring(0,6));
|
+ to);
|
||||||
|
if (_toI2P) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(I2PTunnel.PACKET_DELAY);
|
Thread.sleep(5);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in.available() <= 0)
|
if (in.available() <= 0)
|
||||||
out.flush(); // make sure the data get though
|
out.flush();
|
||||||
|
} else {
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//out.flush(); // close() flushes
|
//out.flush(); // close() flushes
|
||||||
|
Reference in New Issue
Block a user