copy: fix error attribution to progress

This commit is contained in:
Thomas Schoebel-Theuer 2017-03-01 07:42:16 +01:00
parent 3a790eadfc
commit 4e8f5d42e1
1 changed files with 9 additions and 3 deletions

View File

@ -673,15 +673,21 @@ int _run_copy(struct copy_brick *brick)
for (pos = brick->copy_last; pos < brick->copy_end || brick->append_mode > 1; pos = ((pos / COPY_CHUNK) + 1) * COPY_CHUNK) {
int index = GET_INDEX(pos);
struct copy_state *st = &GET_STATE(brick, index);
int this_progress;
if (max-- <= 0) {
break;
}
st->prev = prev;
prev = index;
if (st->active[0] & st->active[1])
break;
// call the finite state automaton
if (!(st->active[0] | st->active[1])) {
progress += _next_state(brick, index, pos);
}
this_progress = _next_state(brick, index, pos);
if (this_progress < 0)
break;
progress += this_progress;
}
// check the resulting state: can we advance the copy_last pointer?