From 4fb18fa9d5fbefb2fa5acc2fa01f7dd921bbd366 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:25:33 +0200 Subject: [PATCH 1/2] Base file extensions in judgedaemon on language config in domserver We still had the .C extension here which has been removed from the domserver for quite a while. The old values are kept if some languages are not available in the API of the domserver. --- judge/judgedaemon.main.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 367b92b4cd..7e3f5360c5 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -385,6 +385,13 @@ function fetch_executable_internal( 'java' => ['java'], 'py' => ['py'], ]; + $domserver_languages = dj_json_decode(request('languages', 'GET')); + foreach ($domserver_languages as $language) { + $id = $language['id']; + if (key_exists($id, $langexts)) { + $langexts[$id] = $language['extensions']; + } + } $buildscript = "#!/bin/sh\n\n"; $execlang = false; $source = ""; From 5c156bb93aaa82e1d2b6a5d132065bb502c77e10 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:36:14 +0200 Subject: [PATCH 2/2] Don't update config for every internal fetched --- judge/judgedaemon.main.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 7e3f5360c5..999bc3bfdb 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -327,6 +327,7 @@ function fetch_executable_internal( $execid, $hash ]); + global $langexts; $execdeploypath = $execdir . '/.deployed'; $execbuilddir = $execdir . '/build'; $execbuildpath = $execbuilddir . '/build'; @@ -379,19 +380,6 @@ function fetch_executable_internal( $do_compile = false; } else { // detect lang and write build file - $langexts = [ - 'c' => ['c'], - 'cpp' => ['cpp', 'C', 'cc'], - 'java' => ['java'], - 'py' => ['py'], - ]; - $domserver_languages = dj_json_decode(request('languages', 'GET')); - foreach ($domserver_languages as $language) { - $id = $language['id']; - if (key_exists($id, $langexts)) { - $langexts[$id] = $language['extensions']; - } - } $buildscript = "#!/bin/sh\n\n"; $execlang = false; $source = ""; @@ -649,6 +637,21 @@ function fetch_executable_internal( // Populate the DOMjudge configuration initially djconfig_refresh(); +// Prepopulate default language extensions, afterwards update based on domserver config +$langexts = [ + 'c' => ['c'], + 'cpp' => ['cpp', 'C', 'cc'], + 'java' => ['java'], + 'py' => ['py'], +]; +$domserver_languages = dj_json_decode(request('languages', 'GET')); +foreach ($domserver_languages as $language) { + $id = $language['id']; + if (key_exists($id, $langexts)) { + $langexts[$id] = $language['extensions']; + } +} + // Constantly check API for unjudged submissions $endpointIDs = array_keys($endpoints); $currentEndpoint = 0;