Skip to content

Commit 4aa054e

Browse files
author
Michael Vasseur
committed
Disable the judgehost instead of killing for local actions
We will only terminate on either: - failure in startup - when communiation with the domserver fails as we can't communicate at that point. Implement Tobi his feedback
1 parent 671da70 commit 4aa054e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

judge/judgedaemon.main.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ function fetch_executable_internal(
392392
$hash
393393
]);
394394
global $langexts;
395+
global $myhost;
395396
$execdeploypath = $execdir . '/.deployed';
396397
$execbuilddir = $execdir . '/build';
397398
$execbuildpath = $execbuilddir . '/build';
@@ -401,11 +402,11 @@ function fetch_executable_internal(
401402
($combined_run_compare && file_get_contents(LIBJUDGEDIR . '/run-interactive.sh')!==file_get_contents($execrunpath))) {
402403
system('rm -rf ' . dj_escapeshellarg($execdir) . ' ' . dj_escapeshellarg($execbuilddir), $retval);
403404
if ($retval !== 0) {
404-
error("Deleting '$execdir' or '$execbuilddir' was unsuccessful.");
405+
disable('judgehost', 'hostname', $myhost, "Deleting '$execdir' or '$execbuilddir' was unsuccessful.");
405406
}
406407
system('mkdir -p ' . dj_escapeshellarg($execbuilddir), $retval);
407408
if ($retval !== 0) {
408-
error("Could not create directory '$execbuilddir'");
409+
disable('judgehost', 'hostname', $myhost, "Could not create directory '$execbuilddir'");
409410
}
410411

411412
logmsg(LOG_INFO, " 💾 Fetching new executable '$type/$execid' with hash '$hash'.");
@@ -454,7 +455,7 @@ function fetch_executable_internal(
454455
$unescapedSource = "";
455456
foreach ($langexts as $lang => $langext) {
456457
if (($handle = opendir($execbuilddir)) === false) {
457-
error("Could not open $execbuilddir");
458+
disable('judgehost', 'hostname', $myhost, "Could not open $execbuilddir");
458459
}
459460
while (($file = readdir($handle)) !== false) {
460461
$ext = pathinfo($file, PATHINFO_EXTENSION);
@@ -499,7 +500,7 @@ function fetch_executable_internal(
499500
break;
500501
}
501502
if (file_put_contents($execbuildpath, $buildscript) === false) {
502-
error("Could not write file 'build' in $execbuilddir");
503+
disable('judgehost', 'hostname', $myhost, "Could not write file 'build' in $execbuilddir");
503504
}
504505
chmod($execbuildpath, 0755);
505506
}
@@ -531,10 +532,10 @@ function fetch_executable_internal(
531532
# team submission and runjury programs and connects their pipes.
532533
$runscript = file_get_contents(LIBJUDGEDIR . '/run-interactive.sh');
533534
if (rename($execrunpath, $execrunjurypath) === false) {
534-
error("Could not move file 'run' to 'runjury' in $execbuilddir");
535+
disable('judgehost', 'hostname', $myhost, "Could not move file 'run' to 'runjury' in $execbuilddir");
535536
}
536537
if (file_put_contents($execrunpath, $runscript) === false) {
537-
error("Could not write file 'run' in $execbuilddir");
538+
disable('judgehost', 'hostname', $myhost, "Could not write file 'run' in $execbuilddir");
538539
}
539540
chmod($execrunpath, 0755);
540541
}
@@ -901,14 +902,14 @@ function fetch_executable_internal(
901902
);
902903
if (isset($error)) {
903904
$scriptId = $judgeTask['run_script_id'];
904-
error("Retrieving/storing debug script '$scriptId' failed.");
905+
disable('judgehost', 'hostname', $myhost, "Retrieving/storing debug script '$scriptId' failed.");
905906
}
906907

907908
$debug_cmd = implode(' ', array_map('dj_escapeshellarg',
908909
[$runpath, $workdir, $tmpfile]));
909910
system($debug_cmd, $retval);
910911
if ($retval !== 0) {
911-
error("Running '$runpath' failed.");
912+
disable('judgehost', 'hostname', $myhost, "Running '$runpath' failed.");
912913
}
913914

914915
request(

0 commit comments

Comments
 (0)