SimpleTimer2: Additional fix for uncaught IllegalStateException

affecting streaming timers (ticket #1672)
Minor streaming cleanup
This commit is contained in:
zzz
2015-10-08 13:42:31 +00:00
parent 03f9df4ff0
commit 419d6a8e18
4 changed files with 34 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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).

View File

@ -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 = "";