Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies #128

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["judge-core", "judge-service", "judge-server", "judge-cli"]
members = ["judge-core", "judge-service", "judge-server", "judge-cli"]
resolver = "2"
4 changes: 2 additions & 2 deletions judge-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "A judge library for online judge system"
[dependencies]
libc = "0.2"
libseccomp = "0.3"
nix = "0.26"
nix = { version = "0.27", features = ["event", "fs", "process", "resource"] }
log = "0.4"
anyhow = "1.0"
serde = "1"
Expand All @@ -19,4 +19,4 @@ serde_json = "1"
serde_yaml = "0.9"

[dev-dependencies]
env_logger = "0.10.0"
env_logger = "0.10.0"
26 changes: 11 additions & 15 deletions judge-core/src/judge/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ use crate::utils::get_pathbuf_str;
use nix::errno::Errno;
use nix::fcntl::{fcntl, FcntlArg, OFlag};
use nix::sys::epoll::{
epoll_create1, epoll_ctl, epoll_wait, EpollCreateFlags, EpollEvent, EpollFlags, EpollOp,
Epoll, EpollCreateFlags, EpollEvent, EpollFlags,
};
use nix::unistd::{pipe, read, write};
use std::fs::File;
use std::os::fd::BorrowedFd;
use std::os::unix::io::{AsRawFd, RawFd};
use std::path::PathBuf;
use std::time::Duration;
Expand Down Expand Up @@ -84,15 +85,10 @@ fn read_msg_from_fd(from: RawFd) -> Result<ProcessExitMessage, JudgeCoreError> {
Ok(msg)
}

fn add_epoll_fd(epoll_fd: RawFd, fd: RawFd) -> Result<(), JudgeCoreError> {
let mut event = EpollEvent::new(EpollFlags::EPOLLIN, fd as u64);
fn add_epoll_fd(epoll: &Epoll, fd: RawFd) -> Result<(), JudgeCoreError> {
let event = EpollEvent::new(EpollFlags::EPOLLIN, fd as u64);
log::debug!("Adding fd={} to epoll", fd);
Ok(epoll_ctl(
epoll_fd,
EpollOp::EpollCtlAdd,
fd,
Some(&mut event),
)?)
Ok(epoll.add(unsafe { BorrowedFd::borrow_raw(fd) }, event)?)
}

pub fn run_interact(
Expand All @@ -101,7 +97,7 @@ pub fn run_interact(
output_path: &String,
) -> Result<Option<JudgeResultInfo>, JudgeCoreError> {
log::debug!("Creating epoll");
let epoll_fd = epoll_create1(EpollCreateFlags::EPOLL_CLOEXEC)?;
let epoll = Epoll::new(EpollCreateFlags::EPOLL_CLOEXEC)?;

log::debug!("Creating interact pipes");
let (proxy_read_user, user_write_proxy) = pipe()?;
Expand All @@ -110,14 +106,14 @@ pub fn run_interact(
let (interactor_read_proxy, proxy_write_interactor) = pipe()?;

log::debug!("Adding read proxy fds to epoll");
add_epoll_fd(epoll_fd, proxy_read_user)?;
add_epoll_fd(epoll_fd, proxy_read_interactor)?;
add_epoll_fd(&epoll, proxy_read_user)?;
add_epoll_fd(&epoll, proxy_read_interactor)?;

log::debug!("Creating exit report pipes with epoll");
let (user_exit_read, user_exit_write) = pipe()?;
let (interactor_exit_read, interactor_exit_write) = pipe()?;
add_epoll_fd(epoll_fd, user_exit_read)?;
add_epoll_fd(epoll_fd, interactor_exit_read)?;
add_epoll_fd(&epoll, user_exit_read)?;
add_epoll_fd(&epoll, interactor_exit_read)?;

let mut user_listener = ProcessListener::new()?;
let mut interact_listener = ProcessListener::new()?;
Expand Down Expand Up @@ -165,7 +161,7 @@ pub fn run_interact(
let mut interactor_exited = false;
let mut option_user_result: Option<RawRunResultInfo> = None;
loop {
let num_events = epoll_wait(epoll_fd, &mut events, -1)?;
let num_events = epoll.wait(&mut events, -1)?;
log::debug!("{} events found!", num_events);

for event in events.iter().take(num_events) {
Expand Down
4 changes: 2 additions & 2 deletions judge-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ tokio = { version = "1", features = ["full"] }
actix-web = "4"

# Openapi generate
utoipa = { version = "3", features = ["actix_extras"] }
utoipa-swagger-ui = { version = "3", features = ["actix-web"] }
utoipa = { version = "4", features = ["actix_extras"] }
utoipa-swagger-ui = { version = "4", features = ["actix-web"] }

# Support global variable
lazy_static = "1.4"
Expand Down
Loading