forked from I2P_Developers/i2p.i2p
SimpleTimer2: Additional fix for uncaught IllegalStateException
affecting streaming timers (ticket #1672) Minor streaming cleanup
This commit is contained in:
@ -1311,7 +1311,9 @@ class Connection {
|
||||
}
|
||||
|
||||
public long getNextSendTime() { return _nextSend; }
|
||||
|
||||
public void timeReached() { retransmit(); }
|
||||
|
||||
/**
|
||||
* Retransmit the packet if we need to.
|
||||
*
|
||||
@ -1323,7 +1325,7 @@ class Connection {
|
||||
*
|
||||
* @return true if the packet was sent, false if it was not
|
||||
*/
|
||||
public boolean retransmit() {
|
||||
private boolean retransmit() {
|
||||
if (_packet.getAckTime() > 0)
|
||||
return false;
|
||||
|
||||
|
@ -257,6 +257,8 @@ public class SimpleTimer2 {
|
||||
private long _nextRun;
|
||||
/** whether this was scheduled during RUNNING state. LOCKING: this */
|
||||
private boolean _rescheduleAfterRun;
|
||||
/** whether this was cancelled during RUNNING state. LOCKING: this */
|
||||
private boolean _cancelAfterRun;
|
||||
|
||||
/** must call schedule() later */
|
||||
public TimedEvent(SimpleTimer2 pool) {
|
||||
@ -290,7 +292,8 @@ public class SimpleTimer2 {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Scheduling: " + this + " timeout = " + timeoutMs + " state: " + _state);
|
||||
if (timeoutMs <= 0) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
// streaming timers do call with timeoutMs == 0
|
||||
if (timeoutMs < 0 && _log.shouldLog(Log.WARN))
|
||||
_log.warn("Timeout <= 0: " + this + " timeout = " + timeoutMs + " state: " + _state);
|
||||
timeoutMs = 1; // otherwise we may execute before _future is updated, which is fine
|
||||
// except it triggers 'early execution' warning logging
|
||||
@ -298,6 +301,7 @@ public class SimpleTimer2 {
|
||||
|
||||
// always set absolute time of execution
|
||||
_nextRun = timeoutMs + System.currentTimeMillis();
|
||||
_cancelAfterRun = false;
|
||||
|
||||
switch(_state) {
|
||||
case RUNNING:
|
||||
@ -373,7 +377,9 @@ public class SimpleTimer2 {
|
||||
case CANCELLED: // fall through
|
||||
case IDLE:
|
||||
break; // my preference is to throw IllegalState here, but let it be.
|
||||
case RUNNING: // fall through
|
||||
case RUNNING:
|
||||
_cancelAfterRun = true;
|
||||
return true;
|
||||
case SCHEDULED:
|
||||
boolean cancelled = _future.cancel(false);
|
||||
if (cancelled)
|
||||
@ -447,6 +453,10 @@ public class SimpleTimer2 {
|
||||
case CANCELLED:
|
||||
break; // nothing
|
||||
case RUNNING:
|
||||
if (_cancelAfterRun) {
|
||||
_cancelAfterRun = false;
|
||||
_state = TimedEventState.CANCELLED;
|
||||
} else {
|
||||
_state = TimedEventState.IDLE;
|
||||
// do we need to reschedule?
|
||||
if (_rescheduleAfterRun) {
|
||||
@ -456,6 +466,7 @@ public class SimpleTimer2 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long time = System.currentTimeMillis() - before;
|
||||
if (time > 500 && _log.shouldLog(Log.WARN))
|
||||
_log.warn(_pool + " event execution took " + time + ": " + this);
|
||||
|
12
history.txt
12
history.txt
@ -1,3 +1,15 @@
|
||||
2015-10-08 zzz
|
||||
* SimpleTimer2: Additional fix for uncaught IllegalStateException
|
||||
affecting streaming timers (ticket #1672)
|
||||
|
||||
2015-10-02 zzz
|
||||
* Router: Don't check config files for reload on Android
|
||||
|
||||
2015-09-28 zzz
|
||||
* Addressbook: Fix isValidDest() for EC/Ed dests
|
||||
* i2psnark: Support adding plain base 32 hashes
|
||||
* Susimail: Hide headers and buttons if search results are empty
|
||||
|
||||
2015-09-27 dg
|
||||
* Router: Fix soft restarts for 'massive' clock jumps (over +150s or -61s) and recover from standby
|
||||
and hibernate (ticket #1014).
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 14;
|
||||
public final static long BUILD = 15;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
Reference in New Issue
Block a user