Changeset 02669fa for router


Ignore:
Timestamp:
Jul 10, 2018 5:14:14 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f6da5f4
Parents:
30fc954
Message:

SSU: Sync/notify improvements (ticket #2260)

Location:
router/java/src/net/i2p/router
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/RouterVersion.java

    r30fc954 r02669fa  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 8;
     21    public final static long BUILD = 9;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/transport/udp/InboundMessageFragments.java

    r30fc954 r02669fa  
    261261        // races in OutboundMessageFragments.
    262262        if (newAck && from.getOutboundMessageCount() > 0)
    263             _outbound.add(from);
     263            _outbound.add(from, 0);
    264264
    265265        return rv;
  • router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java

    r30fc954 r02669fa  
    5151     */
    5252    private Iterator<PeerState> _iterator;
    53 
    54     /**
    55      *  Avoid sync in add() if possible (not 100% reliable)
    56      */
    57     private volatile boolean _isWaiting;
    5853
    5954    private volatile boolean _alive;
     
    105100        _activePeers.clear();
    106101        synchronized (_activePeers) {
    107             _activePeers.notifyAll();
     102            _activePeers.notify();
    108103        }
    109104    }
     
    166161            OutboundMessageState state = new OutboundMessageState(_context, msg, peer);
    167162            peer.add(state);
    168             add(peer);
     163            add(peer, state.fragmentSize(0));
    169164        } catch (IllegalArgumentException iae) {
    170165            _transport.failed(msg, "Peer disconnected quickly");
     
    183178            throw new RuntimeException("null peer for " + state);
    184179        peer.add(state);
    185         add(peer);
     180        add(peer, state.fragmentSize(0));
    186181        //_context.statManager().addRateData("udp.outboundActiveCount", active, 0);
    187182    }
     
    196191            throw new RuntimeException("null peer");
    197192        int sz = states.size();
     193        int min = peer.fragmentSize();
    198194        for (int i = 0; i < sz; i++) {
    199             peer.add(states.get(i));
    200         }
    201         add(peer);
     195            OutboundMessageState state = states.get(i);
     196            peer.add(state);
     197            int fsz = state.fragmentSize(0);
     198            if (fsz < min)
     199                min = fsz;
     200        }
     201        add(peer, min);
    202202        //_context.statManager().addRateData("udp.outboundActiveCount", active, 0);
    203203    }
     
    212212     * the iterator is now... but these issues are the same as before concurrentification.
    213213     *
     214     * @param the minimum size we can send, or 0 to always notify
    214215     * @since 0.8.9
    215216     */
    216     public void add(PeerState peer) {
    217         boolean wasEmpty = _activePeers.isEmpty();
     217    public void add(PeerState peer, int size) {
    218218        boolean added = _activePeers.add(peer);
    219219        if (added) {
     
    230230        // Also note that the iterator in getNextVolley may have alreay passed us,
    231231        // or not reflect the addition.
    232         if (_isWaiting || wasEmpty) {
     232        if (added || size <= 0 || peer.getSendWindowBytesRemaining() >= size) {
    233233            synchronized (_activePeers) {
    234                 _activePeers.notifyAll();
     234                _activePeers.notify();
    235235            }
    236236        }
     
    322322                    // ... unless nextSendDelay says we have more ready now
    323323                    if (states == null && peersProcessed >= _activePeers.size() && nextSendDelay > 0) {
    324                         _isWaiting = true;
    325324                        peersProcessed = 0;
    326325                        // why? we do this in the loop one at a time
     
    342341                            }
    343342                        }
    344                         _isWaiting = false;
    345343                    //} else {
    346344                    //    if (_log.shouldLog(Log.DEBUG))
Note: See TracChangeset for help on using the changeset viewer.