Skip to content

Commit 575ca6e

Browse files
committed
Merge branch 'master' of github.com:blackav/ejudge
2 parents 6d821e5 + 43a4fc8 commit 575ca6e

File tree

6 files changed

+140
-10
lines changed

6 files changed

+140
-10
lines changed

bin/ej-suid-container.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ apply_language_profiles(void)
17721772
limit_rss_size = limit_vm_size;
17731773
limit_vm_size = -1;
17741774
}
1775-
} else if (!strcmp(language_name, "node")) {
1775+
} else if (!strcmp(language_name, "node") || !strcmp(language_name, "tsnode")) {
17761776
enable_sys_fork = 1;
17771777
limit_processes = 20;
17781778
limit_stack_size = 1024 * 1024; // 1M

lib/runlog.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ run_add_record(
338338
uint64_t flags = 0;
339339
int run_to_ignore = -1;
340340

341-
touch_last_update_time_us(state);
342-
343341
state->uuid_hash_last_added_index = -1;
344342
state->uuid_hash_last_added_run_id = -1;
345343
if (!is_hidden) {
@@ -421,6 +419,8 @@ run_add_record(
421419
re.is_vcs = is_vcs;
422420
flags |= RE_SIZE | RE_LOCALE_ID | RE_USER_ID | RE_LANG_ID | RE_PROB_ID | RE_STATUS | RE_TEST | RE_SCORE | RE_IP | RE_SSL_FLAG | RE_VARIANT | RE_IS_HIDDEN | RE_MIME_TYPE | RE_EOLN_TYPE | RE_STORE_FLAGS | RE_IS_VCS;
423421

422+
touch_last_update_time_us(state);
423+
424424
int64_t serial_id = 0;
425425
if (state->iface->append_run) {
426426
i = state->iface->append_run(state->cnts, &re, flags, p_tv, &serial_id, puuid);
@@ -684,9 +684,10 @@ run_is_imported(runlog_state_t state, int runid)
684684
int
685685
run_start_contest(runlog_state_t state, time_t start_time)
686686
{
687+
if (state->head.start_time) ERR_R("Contest already started");
688+
687689
touch_last_update_time_us(state);
688690

689-
if (state->head.start_time) ERR_R("Contest already started");
690691
return state->iface->start(state->cnts, start_time);
691692
}
692693

@@ -1717,8 +1718,6 @@ run_virtual_start(
17171718
int i;
17181719
struct run_entry re;
17191720

1720-
touch_last_update_time_us(state);
1721-
17221721
if (!state->head.start_time) {
17231722
err("run_virtual_start: the contest is not started");
17241723
return -1;
@@ -1732,6 +1731,9 @@ run_virtual_start(
17321731
err("run_virtual_start: virtual contest for %d already started", user_id);
17331732
return -1;
17341733
}
1734+
1735+
touch_last_update_time_us(state);
1736+
17351737
if (state->iface->user_run_header_set_start_time) {
17361738
return state->iface->user_run_header_set_start_time(state->cnts, user_id, t, 1, user_id);
17371739
}
@@ -1779,8 +1781,6 @@ run_virtual_stop(
17791781
time_t exp_stop_time = 0;
17801782
struct run_entry re;
17811783

1782-
touch_last_update_time_us(state);
1783-
17841784
if (!state->head.start_time) {
17851785
err("run_virtual_stop: the contest is not started");
17861786
return -1;
@@ -1799,6 +1799,9 @@ run_virtual_stop(
17991799
err("run_virtual_stop: virtual contest for %d already stopped", user_id);
18001800
return -1;
18011801
}
1802+
1803+
touch_last_update_time_us(state);
1804+
18021805
if (state->iface->user_run_header_set_stop_time) {
18031806
int duration = urh->duration;
18041807
if (duration <= 0) {
@@ -3179,12 +3182,12 @@ run_rebuild_user_run_index(runlog_state_t state, int user_id)
31793182
int
31803183
run_set_run_is_checked(runlog_state_t state, int run_id, int is_checked)
31813184
{
3182-
touch_last_update_time_us(state);
3183-
31843185
if (run_id < 0 || run_id >= state->run_u) ERR_R("bad runid: %d", run_id);
31853186
if (!state->iface->run_set_is_checked) {
31863187
ERR_R("run_set_is_checked is not implemented");
31873188
} else {
3189+
touch_last_update_time_us(state);
3190+
31883191
return state->iface->run_set_is_checked(state->cnts, run_id, is_checked);
31893192
}
31903193
}

scripts/files.make

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ SCRIPTS_IN = \
6666
nasm-x86-version.in\
6767
node.in\
6868
node-version.in\
69+
tsnode.in\
70+
tsnode-version.in\
6971
qb.in\
7072
qb-version.in\
7173
perl.in\

scripts/lang_ids.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ dotnet-vb=74
6161
rars=75
6262
swift=76
6363
custom=77
64+
tsnode=78

scripts/tsnode-version.in

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/sh
2+
# Copyright (c) 2023 Alexander Chernov <[email protected]>
3+
4+
LANG_CONFIG_DIR="@lang_config_dir@"
5+
6+
common_config() {
7+
echo 'long_name="Typescript"'
8+
echo 'src_sfx=".ts"'
9+
echo 'arch="linux-shared"'
10+
echo 'insecure=1'
11+
}
12+
13+
failure() {
14+
rm -f conftest*
15+
echo 'version='
16+
echo 'arg="'"${arg}"'"'
17+
common_config
18+
echo 'NODEPATH=/bin/false'
19+
[ "${verbose}" = 1 ] && echo "no" >&2
20+
exit 1
21+
}
22+
23+
unset LANG
24+
unset LC_ALL
25+
unset LC_MESSAGES
26+
unset LANGUAGE
27+
28+
if [ x"$1" = x-v ]
29+
then
30+
verbose=1
31+
shift
32+
fi
33+
34+
# recheck the language
35+
if [ x"$1" = x-r ]
36+
then
37+
arg="$2"
38+
[ x"$2" != x ] && node="$2"
39+
[ "${node}" = "" ] && node="ts-node"
40+
41+
[ "${verbose}" = 1 ] && echo -n "checking whether TypeScript is available..." >&2
42+
"${node}" --version >/dev/null 2>&1 || failure
43+
version=`"${node}" --version 2>&1 | sed 's/v//g'` || failure
44+
[ "${version}" != "" ] || failure
45+
NODEPATH=`which "${node}"` || failure
46+
[ "${NODEPATH}" != "" ] || failure
47+
echo "#! ${NODEPATH}" > conftest.rb
48+
echo "console.log('yes');" >> conftest.rb
49+
chmod +x ./conftest.rb || failure
50+
./conftest.rb >/dev/null 2>&1 || failure
51+
52+
rm -f ./conftest*
53+
echo 'version="'"${version}"'"'
54+
echo 'arg="'"${arg}"'"'
55+
common_config
56+
echo 'NODEPATH="'"${NODEPATH}"'"'
57+
[ "${verbose}" = 1 ] && echo "yes, ${NODEPATH}, ${version}" >&2
58+
exit 0
59+
fi
60+
61+
if [ x"$1" = x-l ]
62+
then
63+
echo "TypeScript interpreter [https://nodejs.org]"
64+
exit 0
65+
fi
66+
67+
[ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/tsnode.cfg"
68+
69+
if [ -f "${EJUDGE_LANG_CONFIG}" ]
70+
then
71+
. "${EJUDGE_LANG_CONFIG}"
72+
else
73+
NODEPATH=`which ts-node`
74+
fi
75+
76+
if [ x"${NODEPATH}" = x -o x"${NODEPATH}" = x/bin/false ]
77+
then
78+
echo "This language is not supported." >&2
79+
exit 1
80+
fi
81+
82+
if [ x"$1" = x-p ]
83+
then
84+
echo "${NODEPATH}"
85+
exit 0
86+
fi
87+
88+
"${NODEPATH}" --version 2>/dev/null >/dev/null || exit 1
89+
90+
[ x"$1" = x-f ] && echo -n "TypeScript "
91+
92+
"${NODEPATH}" --version 2>&1 | sed 's/v//g'

scripts/tsnode.in

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
# Copyright (c) 2023 Alexander Chernov <[email protected]>
3+
4+
# This is a `compilation' script for the TypeScript (TSNode) language.
5+
# The idea is to append "#!${NODEPATH}" string
6+
# to the beginning of the file.
7+
# Usage: tsnode <input> <output>
8+
9+
# using EJUDGE_FLAGS we may pass additional flags
10+
11+
LANG_CONFIG_DIR="@lang_config_dir@"
12+
[ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/tsnode.cfg"
13+
14+
if [ -f "${EJUDGE_LANG_CONFIG}" ]
15+
then
16+
. "${EJUDGE_LANG_CONFIG}"
17+
else
18+
version="unknown"
19+
NODEPATH="/usr/bin/ts-node"
20+
fi
21+
22+
if [ x"${version}" = x ]
23+
then
24+
echo "This language is not supported." >&2
25+
exit 1
26+
fi
27+
28+
echo "#! ${NODEPATH} ${EJUDGE_FLAGS}" > $2
29+
echo >> $2
30+
cat $1 >> $2
31+
chmod +x $2
32+
exit 0

0 commit comments

Comments
 (0)