Changeset b15ea8b


Ignore:
Timestamp:
Nov 4, 2015 2:57:07 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f8830a7
Parents:
ef428d5
Message:

Timers: Improve OutboundMessageRegistry? locking
SimpleTimer2 cleanups
possible fix for ticket #1694

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/util/SimpleTimer2.java

    ref428d5 rb15ea8b  
    417417                  case RUNNING:
    418418                    throw new IllegalStateException(this + " not possible to be in " + _state);
    419                   case SCHEDULED: // proceed, switch to IDLE in case I need to reschedule
    420                     _state = TimedEventState.IDLE;
     419                  case SCHEDULED:
     420                    // proceed, will switch to IDLE to reschedule
    421421                }
    422422                                               
    423423                // if I was rescheduled by the user, re-submit myself to the executor.
    424                 int difference = (int)(_nextRun - before); // careful with long uptimes
     424                long difference = _nextRun - before; // careful with long uptimes
    425425                if (difference > _fuzz) {
     426                    // proceed, switch to IDLE to reschedule
     427                    _state = TimedEventState.IDLE;
    426428                    schedule(difference);
    427429                    return;
     
    438440                _log.warn(_pool + " no _future " + this);
    439441            // This can be an incorrect warning especially after a schedule(0)
    440             if (_log.shouldLog(Log.WARN) && delay > 100)
    441                 _log.warn(_pool + " early execution " + delay + ": " + this);
    442             else if (_log.shouldLog(Log.WARN) && delay < -1000)
    443                 _log.warn(" late execution " + (0 - delay) + ": " + this + _pool.debug());
     442            if (_log.shouldWarn()) {
     443                if (delay > 100)
     444                    _log.warn(_pool + " early execution " + delay + ": " + this);
     445                else if (delay < -1000)
     446                    _log.warn(" late execution " + (0 - delay) + ": " + this + _pool.debug());
     447            }
    444448            try {
    445449                timeReached();
  • router/java/src/net/i2p/router/transport/OutboundMessageRegistry.java

    ref428d5 rb15ea8b  
    331331                    _log.debug("Expired: " + e + " remaining: " + r + " active: " + a);
    332332            }
    333             if (_nextExpire <= now)
    334                 _nextExpire = now + 10*1000;
    335             schedule(_nextExpire - now);
    336         }
    337 
    338         public void scheduleExpiration(MessageSelector sel) {
     333            synchronized(this) {
     334                if (_nextExpire <= now)
     335                    _nextExpire = now + 10*1000;
     336                schedule(_nextExpire - now);
     337            }
     338        }
     339
     340        public synchronized void scheduleExpiration(MessageSelector sel) {
    339341            long now = _context.clock().now();
    340342            if ( (_nextExpire <= now) || (sel.getExpiration() < _nextExpire) ) {
Note: See TracChangeset for help on using the changeset viewer.