Skip to content

Commit 77dbeb3

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 250dbe4 commit 77dbeb3

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';
@@ -337,11 +338,11 @@ function fetch_executable_internal(
337338
($combined_run_compare && file_get_contents(LIBJUDGEDIR . '/run-interactive.sh')!==file_get_contents($execrunpath))) {
338339
system('rm -rf ' . dj_escapeshellarg($execdir) . ' ' . dj_escapeshellarg($execbuilddir), $retval);
339340
if ($retval !== 0) {
340-
error("Deleting '$execdir' or '$execbuilddir' was unsuccessful.");
341+
disable('judgehost', 'hostname', $myhost, "Deleting '$execdir' or '$execbuilddir' was unsuccessful.");
341342
}
342343
system('mkdir -p ' . dj_escapeshellarg($execbuilddir), $retval);
343344
if ($retval !== 0) {
344-
error("Could not create directory '$execbuilddir'");
345+
disable('judgehost', 'hostname', $myhost, "Could not create directory '$execbuilddir'");
345346
}
346347

347348
logmsg(LOG_INFO, " 💾 Fetching new executable '$type/$execid' with hash '$hash'.");
@@ -390,7 +391,7 @@ function fetch_executable_internal(
390391
$unescapedSource = "";
391392
foreach ($langexts as $lang => $langext) {
392393
if (($handle = opendir($execbuilddir)) === false) {
393-
error("Could not open $execbuilddir");
394+
disable('judgehost', 'hostname', $myhost, "Could not open $execbuilddir");
394395
}
395396
while (($file = readdir($handle)) !== false) {
396397
$ext = pathinfo($file, PATHINFO_EXTENSION);
@@ -435,7 +436,7 @@ function fetch_executable_internal(
435436
break;
436437
}
437438
if (file_put_contents($execbuildpath, $buildscript) === false) {
438-
error("Could not write file 'build' in $execbuilddir");
439+
disable('judgehost', 'hostname', $myhost, "Could not write file 'build' in $execbuilddir");
439440
}
440441
chmod($execbuildpath, 0755);
441442
}
@@ -467,10 +468,10 @@ function fetch_executable_internal(
467468
# team submission and runjury programs and connects their pipes.
468469
$runscript = file_get_contents(LIBJUDGEDIR . '/run-interactive.sh');
469470
if (rename($execrunpath, $execrunjurypath) === false) {
470-
error("Could not move file 'run' to 'runjury' in $execbuilddir");
471+
disable('judgehost', 'hostname', $myhost, "Could not move file 'run' to 'runjury' in $execbuilddir");
471472
}
472473
if (file_put_contents($execrunpath, $runscript) === false) {
473-
error("Could not write file 'run' in $execbuilddir");
474+
disable('judgehost', 'hostname', $myhost, "Could not write file 'run' in $execbuilddir");
474475
}
475476
chmod($execrunpath, 0755);
476477
}
@@ -842,14 +843,14 @@ function fetch_executable_internal(
842843
);
843844
if (isset($error)) {
844845
$scriptId = $judgeTask['run_script_id'];
845-
error("Retrieving/storing debug script '$scriptId' failed.");
846+
disable('judgehost', 'hostname', $myhost, "Retrieving/storing debug script '$scriptId' failed.");
846847
}
847848

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

855856
request(

0 commit comments

Comments
 (0)