Skip to content

Commit 9e00e09

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 d02a6cd commit 9e00e09

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
@@ -328,6 +328,7 @@ function fetch_executable_internal(
328328
$hash
329329
]);
330330
global $langexts;
331+
global $myhost;
331332
$execdeploypath = $execdir . '/.deployed';
332333
$execbuilddir = $execdir . '/build';
333334
$execbuildpath = $execbuilddir . '/build';
@@ -336,11 +337,11 @@ function fetch_executable_internal(
336337
if (!is_dir($execdir) || !file_exists($execdeploypath)) {
337338
system('rm -rf ' . dj_escapeshellarg($execdir) . ' ' . dj_escapeshellarg($execbuilddir), $retval);
338339
if ($retval !== 0) {
339-
error("Deleting '$execdir' or '$execbuilddir' was unsuccessful.");
340+
disable('judgehost', 'hostname', $myhost, "Deleting '$execdir' or '$execbuilddir' was unsuccessful.");
340341
}
341342
system('mkdir -p ' . dj_escapeshellarg($execbuilddir), $retval);
342343
if ($retval !== 0) {
343-
error("Could not create directory '$execbuilddir'");
344+
disable('judgehost', 'hostname', $myhost, "Could not create directory '$execbuilddir'");
344345
}
345346

346347
logmsg(LOG_INFO, " 💾 Fetching new executable '$type/$execid' with hash '$hash'.");
@@ -389,7 +390,7 @@ function fetch_executable_internal(
389390
$unescapedSource = "";
390391
foreach ($langexts as $lang => $langext) {
391392
if (($handle = opendir($execbuilddir)) === false) {
392-
error("Could not open $execbuilddir");
393+
disable('judgehost', 'hostname', $myhost, "Could not open $execbuilddir");
393394
}
394395
while (($file = readdir($handle)) !== false) {
395396
$ext = pathinfo($file, PATHINFO_EXTENSION);
@@ -434,7 +435,7 @@ function fetch_executable_internal(
434435
break;
435436
}
436437
if (file_put_contents($execbuildpath, $buildscript) === false) {
437-
error("Could not write file 'build' in $execbuilddir");
438+
disable('judgehost', 'hostname', $myhost, "Could not write file 'build' in $execbuilddir");
438439
}
439440
chmod($execbuildpath, 0755);
440441
}
@@ -466,10 +467,10 @@ function fetch_executable_internal(
466467
# team submission and runjury programs and connects their pipes.
467468
$runscript = file_get_contents(LIBJUDGEDIR . '/run-interactive.sh');
468469
if (rename($execrunpath, $execrunjurypath) === false) {
469-
error("Could not move file 'run' to 'runjury' in $execbuilddir");
470+
disable('judgehost', 'hostname', $myhost, "Could not move file 'run' to 'runjury' in $execbuilddir");
470471
}
471472
if (file_put_contents($execrunpath, $runscript) === false) {
472-
error("Could not write file 'run' in $execbuilddir");
473+
disable('judgehost', 'hostname', $myhost, "Could not write file 'run' in $execbuilddir");
473474
}
474475
chmod($execrunpath, 0755);
475476
}
@@ -841,14 +842,14 @@ function fetch_executable_internal(
841842
);
842843
if (isset($error)) {
843844
$scriptId = $judgeTask['run_script_id'];
844-
error("Retrieving/storing debug script '$scriptId' failed.");
845+
disable('judgehost', 'hostname', $myhost, "Retrieving/storing debug script '$scriptId' failed.");
845846
}
846847

847848
$debug_cmd = implode(' ', array_map('dj_escapeshellarg',
848849
[$runpath, $workdir, $tmpfile]));
849850
system($debug_cmd, $retval);
850851
if ($retval !== 0) {
851-
error("Running '$runpath' failed.");
852+
disable('judgehost', 'hostname', $myhost, "Running '$runpath' failed.");
852853
}
853854

854855
request(

0 commit comments

Comments
 (0)