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