Skip to content

Commit cd068c5

Browse files
committed
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
1 parent 47efe69 commit cd068c5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

judge/judgedaemon.main.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,12 @@ function fetch_executable_internal(
626626
$new_judging_run = (array) dj_json_decode(base64_decode(file_get_contents($options['j'])));
627627
$judgeTaskId = $options['t'];
628628

629+
$success = false;
629630
for ($i = 0; $i < 5; $i++) {
631+
if ($i > 0) {
632+
$sleep_ms = 100 + random_int(200, ($i+1)*1000);
633+
dj_sleep(0.001 * $sleep_ms);
634+
}
630635
$response = request(
631636
sprintf('judgehosts/add-judging-run/%s/%s', $new_judging_run['hostname'],
632637
urlencode((string)$judgeTaskId)),
@@ -636,11 +641,13 @@ function fetch_executable_internal(
636641
);
637642
if ($response !== null) {
638643
logmsg(LOG_DEBUG, "Adding judging run result for jt$judgeTaskId successful.");
644+
$success = true;
639645
break;
640646
}
641-
logmsg(LOG_WARNING, "Failed to report $judgeTaskId in attempt #" . ($i + 1) . ".");
642-
$sleep_ms = 100 + random_int(200, ($i+1)*1000);
643-
dj_sleep(0.001 * $sleep_ms);
647+
logmsg(LOG_WARNING, "Failed to report jt$judgeTaskId in attempt #" . ($i + 1) . ".");
648+
}
649+
if (!$success) {
650+
error("Final attempt of uploading jt$judgeTaskId was unsuccessful, giving up.");
644651
}
645652
unlink($options['j']);
646653
exit(0);

0 commit comments

Comments
 (0)