diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a96b10a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:18.04 + +ENV LANG C.UTF-8 + +# install python3.6 +RUN apt update && \ + apt install -y software-properties-common && \ + add-apt-repository -y ppa:deadsnakes/ppa && \ + apt install python3.6 + +# install rust +RUN apt install -y curl && \ + curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y +ENV PATH=/root/.cargo/bin:$PATH diff --git a/README.md b/README.md index e69de29..d6bad2c 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,5 @@ +# river + +## 环境要求 + +- linux diff --git a/proto/river.proto b/proto/river.proto index dce610c..0ff7838 100644 --- a/proto/river.proto +++ b/proto/river.proto @@ -25,8 +25,8 @@ message JudgeRequest { } JudgeType judge_type = 3; - string in_data = 4; - string out_data = 5; + bytes in_data = 4; + bytes out_data = 5; int32 time_limit = 6; int32 memory_limit = 7; diff --git a/src/judger.rs b/src/judger.rs index 51fb7bc..fcadc71 100644 --- a/src/judger.rs +++ b/src/judger.rs @@ -78,7 +78,7 @@ pub async fn compile(request: &JudgeRequest, path: &Path) -> Result "main.go", None => return Err(Error::LanguageNotFound(request.language)), }; - if let Err(e) = fs::write(path.join(filename), request.code.clone()).await { + if let Err(e) = fs::write(path.join(filename), &request.code).await { return Err(Error::FileWriteError(e)); }; diff --git a/src/process.rs b/src/process.rs index 374759a..358a00d 100644 --- a/src/process.rs +++ b/src/process.rs @@ -173,19 +173,6 @@ impl Drop for ExecArgs { } } -const ITIMER_REAL: libc::c_int = 0; -extern "C" { - #[cfg_attr( - all(target_os = "macos", target_arch = "x86"), - link_name = "setitimer$UNIX2003" - )] - fn setitimer( - which: libc::c_int, - new_value: *const libc::itimerval, - old_value: *mut libc::itimerval, - ) -> libc::c_int; -} - fn run(process: Process) { // 子进程里崩溃也无法返回,崩溃就直接崩溃了 let exec_args = ExecArgs::build(&process.cmd).unwrap(); @@ -225,7 +212,7 @@ fn run(process: Process) { 0o644, ); // 墙上时钟限制 - if setitimer(ITIMER_REAL, &rt, ptr::null_mut()) == -1 { + if libc::setitimer(libc::ITIMER_REAL, &rt, ptr::null_mut()) == -1 { eprintln!("setitimer failure!"); eprintln!("{:?}", io::Error::last_os_error().raw_os_error()); panic!("How dare you!");