Changeset 00d6a49


Ignore:
Timestamp:
Dec 11, 2015 5:11:16 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
8b9bcbc
Parents:
ea9c4a19
Message:

Router: Don't let context clock shifts affect calculated uptime

File:
1 edited

Legend:

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

    rea9c4a19 r00d6a49  
    523523    /**
    524524     *  Used only by routerconsole.. to be deprecated?
     525     *  @return System time, NOT context time
    525526     */
    526527    public long getWhenStarted() { return _started; }
    527528
    528     /** wall clock uptime */
     529    /**
     530     * Wall clock uptime.
     531     * This uses System time, NOT context time, so context clock shifts will
     532     * not affect it. This is important if NTP fails and the
     533     * clock then shifts from a SSU peer source just after startup.
     534     */
    529535    public long getUptime() {
    530         if ( (_context == null) || (_context.clock() == null) ) return 1; // racing on startup
    531         return Math.max(1, _context.clock().now() - _context.clock().getOffset() - _started);
     536        if (_started <= 0) return 1000; // racing on startup
     537        return Math.max(1000, System.currentTimeMillis() - _started);
    532538    }
    533539   
     
    567573        startupStuff();
    568574        changeState(State.STARTING_2);
    569         _started = _context.clock().now();
     575        _started = System.currentTimeMillis();
    570576        try {
    571577            Runtime.getRuntime().addShutdownHook(_shutdownHook);
Note: See TracChangeset for help on using the changeset viewer.