Skip batches on session change

This commit is contained in:
M66B 2020-09-21 13:34:44 +02:00
parent c77ec0bd10
commit d5e1cf1ae1
1 changed files with 8 additions and 3 deletions

View File

@ -162,7 +162,7 @@ class Core {
Log.i(folder.name + " executing operations=" + ops.size()); Log.i(folder.name + " executing operations=" + ops.size());
while (retry < LOCAL_RETRY_MAX && ops.size() > 0 && while (retry < LOCAL_RETRY_MAX && ops.size() > 0 &&
state.isRunning() && state.isRunning() &&
state.batchCanRun(folder.id, priority, sequence)) { state.batchCanRun(session, folder.id, priority, sequence)) {
TupleOperationEx op = ops.get(0); TupleOperationEx op = ops.get(0);
try { try {
@ -500,7 +500,9 @@ class Core {
ops.remove(op); ops.remove(op);
} else { } else {
retry++; retry++;
if (retry < LOCAL_RETRY_MAX) if (retry < LOCAL_RETRY_MAX &&
state.isRunning() &&
state.batchCanRun(session, folder.id, priority, sequence))
try { try {
Thread.sleep(LOCAL_RETRY_DELAY); Thread.sleep(LOCAL_RETRY_DELAY);
} catch (InterruptedException ex1) { } catch (InterruptedException ex1) {
@ -4251,7 +4253,10 @@ class Core {
} }
} }
boolean batchCanRun(long folder, int priority, long current) { boolean batchCanRun(int session, long folder, int priority, long current) {
if (!this.active || session != this.session)
return false;
synchronized (this) { synchronized (this) {
FolderPriority key = new FolderPriority(folder, priority); FolderPriority key = new FolderPriority(folder, priority);
boolean can = batch.get(key).equals(current); boolean can = batch.get(key).equals(current);