Skip to content

Commit

Permalink
Judgedaemon gather extensions based on domserver config (#2130)
Browse files Browse the repository at this point in the history
* 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.

* Don't update config for every internal fetched
  • Loading branch information
vmcj authored Aug 30, 2023
1 parent 5e32eed commit 8b7fd31
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ function fetch_executable_internal(
$execid,
$hash
]);
global $langexts;
$execdeploypath = $execdir . '/.deployed';
$execbuilddir = $execdir . '/build';
$execbuildpath = $execbuilddir . '/build';
Expand Down Expand Up @@ -379,12 +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'],
];
$buildscript = "#!/bin/sh\n\n";
$execlang = false;
$source = "";
Expand Down Expand Up @@ -642,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;
Expand Down

0 comments on commit 8b7fd31

Please sign in to comment.