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

Fix kqueue memory leak #687

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
11 changes: 7 additions & 4 deletions src/kernel/src/kqueue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use crate::{
process::{FileDesc, VThread},
syscalls::{SysErr, SysIn, SysOut, Syscalls},
};
use std::{convert::Infallible, sync::Arc};
use std::{
convert::Infallible,
sync::{Arc, Weak},
};

pub struct KernelQueueManager {}

Expand Down Expand Up @@ -44,13 +47,13 @@ impl KernelQueueManager {

#[derive(Debug)]
pub struct KernelQueue {
filedesc: Arc<FileDesc>,
filedesc: Weak<FileDesc>,
}

impl KernelQueue {
pub fn new(filedesc: &Arc<FileDesc>) -> Arc<Self> {
Arc::new(KernelQueue {
filedesc: filedesc.clone(),
filedesc: Arc::downgrade(filedesc),
})
}
}
Expand All @@ -70,6 +73,6 @@ impl FileBackend for KernelQueue {
_: TruncateLength,
_: Option<&VThread>,
) -> Result<(), Box<dyn Errno>> {
Err(DefaultError::InvalidValue.into())
Err(Box::new(DefaultError::InvalidValue))
}
}