Skip to content

Commit

Permalink
fix(Judger): 🐛 fix cgroup_id should not be reused
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason0729 committed Jun 9, 2024
1 parent f359af9 commit f6a4c91
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
1 change: 0 additions & 1 deletion judger/src/filesystem/adapter/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ impl From<FuseError> for fuse3::Errno {
FuseError::AlreadyExist => libc::EEXIST,
_ => {
log::warn!("FUSE driver broken: {}", value);
panic!("test");
libc::EINVAL
}
}
Expand Down
14 changes: 5 additions & 9 deletions judger/src/filesystem/adapter/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ where
) -> impl Future<Output = FuseResult<()>> + Send {
async move {
let node = self.handle_table.get(fh).ok_or(FuseError::HandleNotFound)?;
// The result is intentionally ignored, from the behavior of `ld`,
// we know that ld actually flush readonly file.
Entry::flush(node).await.ok_or(FuseError::Unimplemented);
Ok(())
}
Expand Down Expand Up @@ -417,7 +419,6 @@ where
Ok(reply_attr(&req, node.get_value(), inode))
}
}
// open and create fd
fn create(
&self,
req: Request,
Expand All @@ -436,16 +437,11 @@ where
.insert(name.to_os_string(), Entry::new_file())
.ok_or(FuseError::AlreadyExist)?;

let mut entry = node.get_value().clone();
if flags & u32::from_ne_bytes(libc::O_APPEND.to_ne_bytes()) != 0 {
entry.set_append().await;
}

let entry = node.get_value().clone();
let fh = self.handle_table.add(AsyncMutex::new(entry));

let inode = node.get_id() as u64;
let entry = node.get_value();
Ok(reply_created(&req, entry, fh, flags, inode))

Ok(reply_created(&req, node.get_value(), fh, flags, inode))
}
}
fn mkdir(
Expand Down
3 changes: 0 additions & 3 deletions judger/src/filesystem/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn to_internal_path<'a>(path: &'a Path) -> impl Iterator<Item = &OsStr> + 'a
Component::RootDir | Component::CurDir | Component::ParentDir => None,
Component::Normal(x) => Some(x),
})
// .collect::<Vec<_>>()
}

/// A node on adjacency table
Expand Down Expand Up @@ -295,8 +294,6 @@ impl<'a, V> NodeWrapperMut<'a, V> {

#[cfg(test)]
mod test {
use std::os::unix::ffi::OsStrExt;

use super::*;
#[test]
fn test_adj_table() {
Expand Down
4 changes: 2 additions & 2 deletions judger/src/sandbox/monitor/mem_cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ impl super::Monitor for Monitor {
/// by polling the cgroup, therefore the delay requirespecial attention,
/// it is only guaranteed to below limitation provided + [`MONITOR_ACCURACY`].
async fn stat(self) -> Self::Resource {
// there should be no process left
// FIXME: check running process, this line is commented out because of uncollected process
// uncollected process is at state of not running, but pid is still in use
// debug_assert!(self.cgroup.tasks().is_empty());
// poll once more to get final stat
let wrapper = wrapper::CgroupWrapper::new(&self.cgroup);
(wrapper.memory(), wrapper.cpu())
}
Expand Down

0 comments on commit f6a4c91

Please sign in to comment.