Changeset 67859f6


Ignore:
Timestamp:
Jul 9, 2013 1:55:09 PM (7 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
9e12801, d3e0161
Parents:
b486ae5
Message:

Make activeResends field atomic

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/Connection.java

    rb486ae5 r67859f6  
    77import java.util.Map;
    88import java.util.TreeMap;
     9import java.util.concurrent.atomic.AtomicInteger;
    910import java.util.concurrent.atomic.AtomicLong;
    1011
     
    7071    private final Object _connectLock;
    7172    /** how many messages have been resent and not yet ACKed? */
    72     private int _activeResends;
     73    private final AtomicInteger _activeResends = new AtomicInteger(0);
    7374    private final ConEvent _connectionEvent;
    7475    private final int _randomWait;
     
    198199                int wsz = _options.getWindowSize();
    199200                if (unacked >= wsz ||
    200                     _activeResends >= (wsz + 1) / 2 ||
     201                    _activeResends.get() >= (wsz + 1) / 2 ||
    201202                    _lastSendId.get() - _highestAckedThrough >= Math.max(MAX_WINDOW_SIZE, 2 * wsz)) {
    202203                    if (timeoutMs > 0) {
     
    490491                    _ackedPackets++;
    491492                    if (p.getNumSends() > 1) {
    492                         _activeResends--;
     493                        _activeResends.decrementAndGet();
    493494                        if (_log.shouldLog(Log.DEBUG))
    494495                            _log.debug("Active resend of " + p + " successful, # active left: " + _activeResends);
     
    496497                }
    497498            }
    498             if ( (_outboundPackets.isEmpty()) && (_activeResends != 0) ) {
     499            if ( (_outboundPackets.isEmpty()) && (_activeResends.get() != 0) ) {
    499500                if (_log.shouldLog(Log.INFO))
    500501                    _log.info("All outbound packets acked, clearing " + _activeResends);
    501                 _activeResends = 0;
     502                _activeResends.set(0);
    502503            }
    503504            _outboundPackets.notifyAll();
     
    11731174                if (_packet.getSequenceNum() == _highestAckedThrough + 1 ||
    11741175                    _packet.getNumSends() > 1 ||
    1175                     _activeResends < Math.max(3, (_options.getWindowSize() + 1) / 2))
     1176                    _activeResends.get() < Math.max(3, (_options.getWindowSize() + 1) / 2))
    11761177                    isLowest = true;
    11771178                if (_outboundPackets.containsKey(Long.valueOf(_packet.getSequenceNum())))
     
    12701271                        // first resend for this packet ?
    12711272                        if (numSends == 2)
    1272                             _activeResends++;
     1273                            _activeResends.incrementAndGet();
    12731274                        if (_log.shouldLog(Log.INFO))
    12741275                            _log.info("Resent packet " +
     
    12911292                // acked during resending (... or somethin') ????????????
    12921293                if ( (_packet.getAckTime() > 0) && (_packet.getNumSends() > 1) ) {
    1293                     _activeResends--;
     1294                    _activeResends.decrementAndGet();
    12941295                    synchronized (_outboundPackets) {
    12951296                        _outboundPackets.notifyAll();
  • router/java/src/net/i2p/router/RouterVersion.java

    rb486ae5 r67859f6  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 19;
     21    public final static long BUILD = 20;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.