forked from I2P_Developers/i2p.i2p
SSU: More consolidation of clock().now() calls
This commit is contained in:
@@ -286,9 +286,10 @@ class OutboundMessageFragments {
|
||||
// if there is nothing left to send.
|
||||
// Otherwise, return the volley to be sent.
|
||||
// Otherwise, wait()
|
||||
long now = _context.clock().now();
|
||||
while (_iterator.hasNext()) {
|
||||
peer = _iterator.next();
|
||||
int remaining = peer.finishMessages();
|
||||
int remaining = peer.finishMessages(now);
|
||||
if (remaining <= 0) {
|
||||
// race with add()
|
||||
_iterator.remove();
|
||||
|
@@ -116,6 +116,13 @@ class OutboundMessageState implements CDPQEntry {
|
||||
return _expiration < _context.clock().now();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 0.9.38
|
||||
*/
|
||||
public boolean isExpired(long now) {
|
||||
return _expiration < now;
|
||||
}
|
||||
|
||||
public synchronized boolean isComplete() {
|
||||
return _fragmentAcks == 0;
|
||||
}
|
||||
|
@@ -1560,7 +1560,7 @@ public class PeerState {
|
||||
*
|
||||
* @return number of active outbound messages remaining
|
||||
*/
|
||||
public int finishMessages() {
|
||||
public int finishMessages(long now) {
|
||||
// short circuit, unsynchronized
|
||||
if (_outboundMessages.isEmpty())
|
||||
return _outboundQueue.size();
|
||||
@@ -1582,7 +1582,7 @@ public class PeerState {
|
||||
_retransmitter = null;
|
||||
if (succeeded == null) succeeded = new ArrayList<OutboundMessageState>(4);
|
||||
succeeded.add(state);
|
||||
} else if (state.isExpired()) {
|
||||
} else if (state.isExpired(now)) {
|
||||
iter.remove();
|
||||
if (_retransmitter == state)
|
||||
_retransmitter = null;
|
||||
@@ -1789,7 +1789,7 @@ public class PeerState {
|
||||
long now = _context.clock().now();
|
||||
if (state.getNextSendTime() <= now) {
|
||||
OutboundMessageState retrans = _retransmitter;
|
||||
if ( (retrans != null) && ( (retrans.isExpired() || retrans.isComplete()) ) ) {
|
||||
if ( (retrans != null) && ( (retrans.isExpired(now) || retrans.isComplete()) ) ) {
|
||||
_retransmitter = null;
|
||||
retrans = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user