2007-11-26 zzz

* i2psnark: add timeout for receive inactivity
This commit is contained in:
zzz
2007-11-26 21:53:58 +00:00
committed by zzz
parent 4ebcc95d9f
commit c6a1112f0a
5 changed files with 18 additions and 9 deletions

View File

@ -461,10 +461,12 @@ public class Peer implements Comparable
public long getInactiveTime() {
PeerState s = state;
if (s != null) {
PeerConnectionIn in = s.in;
PeerConnectionOut out = s.out;
if (out != null)
return System.currentTimeMillis() - out.lastSent;
else
if (in != null && out != null) {
long now = System.currentTimeMillis();
return Math.max(now - out.lastSent, now - in.lastRcvd);
} else
return -1; //"state, no out";
} else {
return -1; //"no state";