Changeset d389b3b for apps


Ignore:
Timestamp:
Apr 3, 2019 1:21:41 PM (20 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c3aa4598
Parents:
b7d980d
Message:

I2PTunnel: Start/stop POST throttle timer

Location:
apps/i2ptunnel/java/src/net/i2p/i2ptunnel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ConnThrottler.java

    rb7d980d rd389b3b  
    4040    private final Log _log;
    4141    private final DateFormat _fmt;
    42 
    43     /*
     42    private final SimpleTimer2.TimedEvent _cleaner;
     43    private boolean _isRunning;
     44
     45    /*
     46     * Caller MUST call start()
     47     *
    4448     * @param max per-peer, 0 for unlimited
    4549     * @param totalMax for all peers, 0 for unlimited
     
    5862        _fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
    5963        _fmt.setTimeZone(SystemVersion.getSystemTimeZone());
    60         new Cleaner();
     64        _cleaner = new Cleaner();
     65    }
     66
     67    /*
     68     * If already started, has no effect.
     69     *
     70     * @since 0.9.40
     71     */
     72    public synchronized void start() {
     73        if (_isRunning)
     74            return;
     75        _isRunning = true;
     76        _cleaner.schedule(_checkPeriod);
     77    }
     78
     79    /*
     80     * May be restarted.
     81     *
     82     * @since 0.9.40
     83     */
     84    public synchronized void stop() {
     85        _isRunning = false;
     86        _cleaner.cancel();
     87        clear();
    6188    }
    6289
     
    177204
    178205    private class Cleaner extends SimpleTimer2.TimedEvent {
    179         /** schedules itself */
     206        /** must call schedule() later */
    180207        public Cleaner() {
    181             super(SimpleTimer2.getInstance(), _checkPeriod);
     208            super(SimpleTimer2.getInstance());
    182209        }
    183210
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPServer.java

    rb7d980d rd389b3b  
    234234                else
    235235                    _postThrottler.updateLimits(pp, pt, pw, pb, px);
     236                _postThrottler.start();
    236237            }
    237238        }
     
    255256        synchronized(this) {
    256257            if (_postThrottler != null)
    257                 _postThrottler.clear();
     258                _postThrottler.stop();
    258259        }
    259260        return super.close(forced);
Note: See TracChangeset for help on using the changeset viewer.