From 0ebe82226e6ba78fbc46b0a52000f50a85f5c17c Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Sat, 26 Jul 2025 14:18:20 +0200 Subject: [PATCH] Minor improvements to async judgetask reporting. - sleep at the start of the loop, so we don't sleep after the final attempt failed - make it more clear what the number means by adding `jt` as we do in other places - error out, do not unlink if final attempt is unsuccessful --- judge/judgedaemon.main.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 8bed70a16e..314a132f73 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -626,7 +626,12 @@ function fetch_executable_internal( $new_judging_run = (array) dj_json_decode(base64_decode(file_get_contents($options['j']))); $judgeTaskId = $options['t']; + $success = false; for ($i = 0; $i < 5; $i++) { + if ($i > 0) { + $sleep_ms = 100 + random_int(200, ($i+1)*1000); + dj_sleep(0.001 * $sleep_ms); + } $response = request( sprintf('judgehosts/add-judging-run/%s/%s', $new_judging_run['hostname'], urlencode((string)$judgeTaskId)), @@ -636,11 +641,13 @@ function fetch_executable_internal( ); if ($response !== null) { logmsg(LOG_DEBUG, "Adding judging run result for jt$judgeTaskId successful."); + $success = true; break; } - logmsg(LOG_WARNING, "Failed to report $judgeTaskId in attempt #" . ($i + 1) . "."); - $sleep_ms = 100 + random_int(200, ($i+1)*1000); - dj_sleep(0.001 * $sleep_ms); + logmsg(LOG_WARNING, "Failed to report jt$judgeTaskId in attempt #" . ($i + 1) . "."); + } + if (!$success) { + error("Final attempt of uploading jt$judgeTaskId was unsuccessful, giving up."); } unlink($options['j']); exit(0);