Changeset c1a8c8a


Ignore:
Timestamp:
Jun 7, 2009 5:35:02 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
51faed2
Parents:
45d9f9d (diff), 4975d30 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

propagate from branch 'i2p.i2p.zzz.test' (head ff346bd41de699648bb66488ec9c0f1f4b5300b1)

to branch 'i2p.i2p' (head 2914d3356f892de25a745f061129704f8b943fc5)

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

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    r45d9f9d rc1a8c8a  
    380380     * talking with.
    381381     *
    382      */
    383     /*
    384     private void selectActiveNotFailingPeers(int howMany, Set exclude, Set matches) {
    385         if (true) {
    386             selectAllNotFailingPeers(howMany, exclude, matches);
    387             return;
    388         }
    389         // pick out the not-failing peers that we're actively talking with
     382     * We use commSystem().isEstablished(), not profile.getIsActive(), as the
     383     * NTCP idle time is now shorter than the 5 minute getIsActive() threshold,
     384     * and we're using this to try and limit connections.
     385     *
     386     * Caution, this does NOT cascade further to non-connected peers, so it should only
     387     * be used when there is a good number of connected peers.
     388     *
     389     * @param exclude non-null
     390     * No mask parameter, to be fixed
     391     */
     392    public void selectActiveNotFailingPeers(int howMany, Set exclude, Set matches) {
    390393        if (matches.size() < howMany) {
    391             synchronized (_reorganizeLock) {
    392                 for (Iterator iter = _notFailingPeers.keySet().iterator(); iter.hasNext(); ) {
    393                     Hash peer = (Hash)iter.next();
    394                     if ( (exclude != null) && exclude.contains(peer) ) continue;
    395                     if (matches.contains(peer)) continue;
    396                     PeerProfile prof = (PeerProfile)_notFailingPeers.get(peer);
    397                     if (prof.getIsActive())
    398                         matches.add(peer);
    399                     if (matches.size() >= howMany)
    400                         return;
     394            getReadLock();
     395            try {
     396                for (Iterator<Hash> iter = _notFailingPeers.keySet().iterator(); iter.hasNext(); ) {
     397                    Hash peer = iter.next();
     398                    if (!_context.commSystem().isEstablished(peer))
     399                        exclude.add(peer);
    401400                }
    402             }
    403         }
    404         // ok, still not enough, pick out the not-failing peers that we aren't talking with
    405         if (matches.size() < howMany)
    406             selectAllNotFailingPeers(howMany, exclude, matches);
    407         return;
    408     }
    409     */
     401                locked_selectPeers(_notFailingPeers, howMany, exclude, matches, 0);
     402            } finally { releaseReadLock(); }
     403        }
     404    }
     405
    410406    /**
    411407     * Return a set of Hashes for peers that are not failing.
     
    415411        selectAllNotFailingPeers(howMany, exclude, matches, onlyNotFailing, 0);
    416412    }
     413    /**
     414     * @param mask ignored, should call locked_selectPeers, to be fixed
     415     *
     416     */
    417417    private void selectAllNotFailingPeers(int howMany, Set exclude, Set matches, boolean onlyNotFailing, int mask) {
    418418        if (matches.size() < howMany) {
  • router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java

    r45d9f9d rc1a8c8a  
    4343        HashSet matches = new HashSet(length);
    4444        boolean exploreHighCap = shouldPickHighCap(ctx);
     45        //
     46        // We don't honor IP Restriction here, to be fixed
     47        //
    4548        if (exploreHighCap)
    4649            ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches);
    47         else
     50        else if (ctx.commSystem().haveOutboundCapacity())
    4851            ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false);
     52        else // use only connected peers so we don't make more connections
     53            ctx.profileOrganizer().selectActiveNotFailingPeers(length, exclude, matches);
    4954       
    5055        if (l.shouldLog(Log.DEBUG))
Note: See TracChangeset for help on using the changeset viewer.