Changeset 8a06027 for router


Ignore:
Timestamp:
Dec 19, 2018 10:51:53 AM (17 months ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
021375b
Parents:
20876ff
Message:

Get call to system timer out of tight loop when counting connections

Location:
router/java/src/net/i2p/router/transport/ntcp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    r20876ff r8a06027  
    416416    /** @return milliseconds */
    417417    public long getTimeSinceSend() { return _context.clock().now()-_lastSendTime; }
     418   
     419    public long getTimeSinceSend(long now) { return now - _lastSendTime; }
    418420
    419421    /** @return milliseconds */
    420422    public long getTimeSinceReceive() { return _context.clock().now()-_lastReceiveTime; }
     423   
     424    public long getTimeSinceReceive(long now) { return now - _lastReceiveTime; }
    421425
    422426    /** @return milliseconds */
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    r20876ff r8a06027  
    708708     */
    709709    public int countActivePeers() {
     710        final long now = _context.clock().now();
    710711        int active = 0;
    711712        for (NTCPConnection con : _conByIdent.values()) {
    712713            // con initializes times at construction,
    713714            // so check message count also
    714             if ((con.getMessagesSent() > 0 && con.getTimeSinceSend() <= 5*60*1000) ||
    715                 (con.getMessagesReceived() > 0 && con.getTimeSinceReceive() <= 5*60*1000)) {
     715            if ((con.getMessagesSent() > 0 && con.getTimeSinceSend(now) <= 5*60*1000) ||
     716                (con.getMessagesReceived() > 0 && con.getTimeSinceReceive(now) <= 5*60*1000)) {
    716717                active++;
    717718            }
Note: See TracChangeset for help on using the changeset viewer.