From 9ed763b611edd5a625a57d82fe4aaab1a790bf98 Mon Sep 17 00:00:00 2001 From: Grische Date: Sat, 12 Mar 2022 12:43:10 +0100 Subject: [PATCH] Fix and simplify confirmJob loop Condition 'ret != ServerCode.OK' is always 'true' as the switch above already breaks in case it is OK. With the initial index of nb_try=1, the loop was never able to reach a maximum tries of 3 (max_try=3). --- src/com/sheepit/client/Client.java | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 842062d..673ddfc 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -1035,12 +1035,22 @@ import okhttp3.HttpUrl; this.log.debug(checkpoint, "path frame " + ajob.getOutputImagePath()); this.isValidatingJob = true; - int nb_try = 1; int max_try = 3; ServerCode ret = ServerCode.UNKNOWN; Type confirmJobReturnCode = Error.Type.OK; retryLoop: - while (nb_try < max_try && ret != ServerCode.OK) { + for (int nb_try = 0; nb_try < max_try; nb_try++) { + if (nb_try >= 1) { + // sleep before retrying + this.log.debug(checkpoint, "Sleep for 32s before trying to re-upload the frame"); + try { + Thread.sleep(32000); + } + catch (InterruptedException e) { + confirmJobReturnCode = Error.Type.UNKNOWN; + } + } + ret = this.server.HTTPSendFile(url_real, ajob.getOutputImagePath(), checkpoint, this.gui); switch (ret) { case OK: @@ -1070,17 +1080,6 @@ import okhttp3.HttpUrl; // do nothing, try to do a request on the next loop break; } - - nb_try++; - if (ret != ServerCode.OK && nb_try < max_try) { - try { - this.log.debug(checkpoint, "Sleep for 32s before trying to re-upload the frame"); - Thread.sleep(32000); - } - catch (InterruptedException e) { - confirmJobReturnCode = Error.Type.UNKNOWN; - } - } } this.isValidatingJob = false;