Changeset 74ed9741 for router


Ignore:
Timestamp:
Jan 4, 2019 1:48:38 PM (20 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3b7284c
Parents:
4786081
Message:

NetDb?: Prevent ISJ deadlock (ticket #2366)

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

Legend:

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

    r4786081 r74ed9741  
    4141     */
    4242    public abstract DatabaseEntry lookupLocally(Hash key);
     43   
     44    /**
     45     *  Not for use without validation
     46     *  @return RouterInfo, LeaseSet, or null, NOT validated
     47     *  @since 0.9.38
     48     */
     49    public abstract DatabaseEntry lookupLocallyWithoutValidation(Hash key);
     50
    4351    public abstract void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs);
    4452   
  • router/java/src/net/i2p/router/RouterVersion.java

    r4786081 r74ed9741  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 13;
     21    public final static long BUILD = 14;
    2222
    2323    /** for example "-test" */
  • router/java/src/net/i2p/router/dummy/DummyNetworkDatabaseFacade.java

    r4786081 r74ed9741  
    4141   
    4242    public DatabaseEntry lookupLocally(Hash key) { return null; }
     43    public DatabaseEntry lookupLocallyWithoutValidation(Hash key) { return null; }
    4344    public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs) {}
    4445    public void lookupLeaseSet(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, Hash fromLocalDest) {}
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    r4786081 r74ed9741  
    493493     *  Not for use without validation
    494494     *  @return RouterInfo, LeaseSet, or null, NOT validated
    495      *  @since 0.9.9
    496      */
    497     DatabaseEntry lookupLocallyWithoutValidation(Hash key) {
     495     *  @since 0.9.9, public since 0.9.38
     496     */
     497    public DatabaseEntry lookupLocallyWithoutValidation(Hash key) {
    498498        if (!_initialized)
    499499            return null;
     
    639639    }
    640640   
     641    /**
     642     * This will return immediately with the result or null.
     643     * However, this may still fire off a lookup if the RI is present but expired (and will return null).
     644     * This may result in deadlocks.
     645     * For true local only, use lookupLocallyWithoutValidation()
     646     */
    641647    public RouterInfo lookupRouterInfoLocally(Hash key) {
    642648        if (!_initialized) return null;
  • router/java/src/net/i2p/router/util/MaskedIPSet.java

    r4786081 r74ed9741  
    55import java.util.Set;
    66
     7import net.i2p.data.DatabaseEntry;
    78import net.i2p.data.DataHelper;
    89import net.i2p.data.Hash;
     
    3334      * As of 0.9.24, returned set will include netdb family as well.
    3435      *
     36      * This gets the peer from the netdb without validation,
     37      * for efficiency and to avoid deadlocks.
     38      * Peers are presumed to be validated elsewhere.
     39      *
    3540      * @param peer non-null
    3641      * @param mask is 1-4 (number of bytes to match)
    3742      */
    3843    public MaskedIPSet(RouterContext ctx, Hash peer, int mask) {
    39         this(ctx, peer, ctx.netDb().lookupRouterInfoLocally(peer), mask);
     44        this(ctx, peer, lookupRILocally(ctx, peer), mask);
     45    }
     46
     47    /**
     48      * This gets the peer from the netdb without validation,
     49      * for efficiency and to avoid deadlocks.
     50      *
     51      * @since 0.9.38
     52      */
     53    private static RouterInfo lookupRILocally(RouterContext ctx, Hash peer) {
     54        DatabaseEntry ds = ctx.netDb().lookupLocallyWithoutValidation(peer);
     55        if (ds != null) {
     56            if (ds.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO)
     57                return (RouterInfo) ds;
     58        }
     59        return null;
    4060    }
    4161
Note: See TracChangeset for help on using the changeset viewer.