Changeset 55e36ee


Ignore:
Timestamp:
Jun 6, 2015 4:01:39 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
9f2ded6
Parents:
7c13fb2
Message:

Console: Add indication of current ff status on /configadvanced,
change immediately when config changes, force republish
Router: RI rebuild locking

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHandler.java

    r7c13fb2 r55e36ee  
    88
    99import net.i2p.data.DataHelper;
     10import net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade;
    1011
    1112/**
     
    8485    private void saveFF() {
    8586        boolean saved = _context.router().saveConfig(ConfigAdvancedHelper.PROP_FLOODFILL_PARTICIPANT, _ff);
     87        if (_ff.equals("false") || _ff.equals("true")) {
     88            FloodfillNetworkDatabaseFacade fndf = (FloodfillNetworkDatabaseFacade) _context.netDb();
     89            boolean wasFF = fndf.floodfillEnabled();
     90            boolean isFF = _ff.equals("true");
     91            fndf.setFloodfillEnabled(isFF);
     92            if (wasFF != isFF)
     93                _context.router().rebuildRouterInfo();
     94        }
    8695        if (saved)
    8796            addFormNotice(_("Configuration saved successfully"));
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigAdvancedHelper.java

    r7c13fb2 r55e36ee  
    3636        return "";
    3737    }
     38
     39    /** @since 0.9.21 */
     40    public boolean isFloodfill() {
     41        return _context.netDb().floodfillEnabled();
     42    }
    3843}
  • apps/routerconsole/jsp/configadvanced.jsp

    r7c13fb2 r55e36ee  
    2626 <div class="wideload">
    2727<h3><%=intl._("Floodfill Configuration")%></h3>
    28 <p><%=intl._("Floodill participation helps the network, but may use more of your computer's resources.")%></p>
     28<p><%=intl._("Floodill participation helps the network, but may use more of your computer's resources.")%>
     29</p><p>
     30<%
     31    if (advancedhelper.isFloodfill()) {
     32%><%=intl._("This router is currently a floodfill participant.")%><%
     33    } else {
     34%><%=intl._("This router is not currently a floodfill participant.")%><%
     35    }
     36%>
     37</p>
    2938<form action="" method="POST">
    3039<input type="hidden" name="nonce" value="<%=pageNonce%>" >
  • router/java/src/net/i2p/router/Router.java

    r7c13fb2 r55e36ee  
    7373    private String _configFilename;
    7474    private RouterInfo _routerInfo;
     75    private final Object _routerInfoLock = new Object();
    7576    /** not for external use */
    7677    public final Object routerInfoFileLock = new Object();
     
    490491     *  Warning, may be null if called very early.
    491492     */
    492     public RouterInfo getRouterInfo() { return _routerInfo; }
     493    public RouterInfo getRouterInfo() {
     494        synchronized (_routerInfoLock) {
     495            return _routerInfo;
     496        }
     497    }
    493498
    494499    /**
     
    497502     */
    498503    public void setRouterInfo(RouterInfo info) {
    499         _routerInfo = info;
     504        synchronized (_routerInfoLock) {
     505            _routerInfo = info;
     506        }
    500507        if (_log.shouldLog(Log.INFO))
    501508            _log.info("setRouterInfo() : " + info, new Exception("I did it"));
     
    818825        if (_log.shouldLog(Log.INFO))
    819826            _log.info("Rebuilding new routerInfo");
     827        synchronized (_routerInfoLock) {
     828            locked_rebuildRouterInfo(blockingRebuild);
     829        }
     830    }
    820831       
     832
     833    /**
     834     * Rebuild and republish our routerInfo since something significant
     835     * has changed.
     836     */
     837    private void locked_rebuildRouterInfo(boolean blockingRebuild) {
    821838        RouterInfo ri = null;
    822839        if (_routerInfo != null)
     
    958975   
    959976    public boolean isHidden() {
    960         RouterInfo ri = _routerInfo;
     977        RouterInfo ri;
     978        synchronized (_routerInfoLock) {
     979            ri = _routerInfo;
     980        }
    961981        if ( (ri != null) && (ri.isHidden()) )
    962982            return true;
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    r7c13fb2 r55e36ee  
    278278    protected PeerSelector createPeerSelector() { return new FloodfillPeerSelector(_context); }
    279279   
    280     synchronized void setFloodfillEnabled(boolean yes) {
     280    public synchronized void setFloodfillEnabled(boolean yes) {
    281281        _floodfillEnabled = yes;
    282282        if (yes && _floodThrottler == null) {
Note: See TracChangeset for help on using the changeset viewer.