mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-22 19:34:06 +03:00
Format Rust code using rustfmt
This commit is contained in:
parent
de003dca0d
commit
cce79118ae
@ -104,9 +104,8 @@ pub async fn fd_manager(
|
||||
2,
|
||||
format!(
|
||||
"Have {} open >= {} max fds; sending Cull Request...",
|
||||
state.total_fds,
|
||||
state.max_fds,
|
||||
)
|
||||
state.total_fds, state.max_fds,
|
||||
),
|
||||
)
|
||||
.send(&send_to_terminal)
|
||||
.await;
|
||||
@ -139,9 +138,7 @@ fn handle_message(
|
||||
assert!(state.total_fds >= number_closed);
|
||||
let return_value = Some(format!(
|
||||
"{} closed {} of {}",
|
||||
km.source.process,
|
||||
number_closed,
|
||||
state.total_fds,
|
||||
km.source.process, number_closed, state.total_fds,
|
||||
));
|
||||
state.total_fds -= number_closed;
|
||||
state
|
||||
|
@ -1,9 +1,9 @@
|
||||
use dashmap::DashMap;
|
||||
use lib::types::core::{
|
||||
Address, CapMessage, CapMessageSender, Capability, DirEntry, FdManagerRequest, FileMetadata, FileType,
|
||||
KernelMessage, LazyLoadBlob, Message, MessageReceiver, MessageSender, PackageId, PrintSender,
|
||||
Printout, ProcessId, Request, Response, VfsAction, VfsError, VfsRequest, VfsResponse,
|
||||
FD_MANAGER_PROCESS_ID, KERNEL_PROCESS_ID, VFS_PROCESS_ID,
|
||||
Address, CapMessage, CapMessageSender, Capability, DirEntry, FdManagerRequest, FileMetadata,
|
||||
FileType, KernelMessage, LazyLoadBlob, Message, MessageReceiver, MessageSender, PackageId,
|
||||
PrintSender, Printout, ProcessId, Request, Response, VfsAction, VfsError, VfsRequest,
|
||||
VfsResponse, FD_MANAGER_PROCESS_ID, KERNEL_PROCESS_ID, VFS_PROCESS_ID,
|
||||
};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
@ -205,7 +205,9 @@ impl Files {
|
||||
self.update_access_order(&path).await;
|
||||
crate::fd_manager::send_fd_manager_open(&self.our, 1, &self.send_to_loop)
|
||||
.await
|
||||
.map_err(|e| VfsError::Other { error: e.to_string() })?;
|
||||
.map_err(|e| VfsError::Other {
|
||||
error: e.to_string(),
|
||||
})?;
|
||||
Ok(file)
|
||||
}
|
||||
|
||||
@ -213,7 +215,9 @@ impl Files {
|
||||
if self.open_files.remove(path).is_some() {
|
||||
crate::fd_manager::send_fd_manager_close(&self.our, 1, &self.send_to_loop)
|
||||
.await
|
||||
.map_err(|e| VfsError::Other { error: e.to_string() })?;
|
||||
.map_err(|e| VfsError::Other {
|
||||
error: e.to_string(),
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -250,7 +254,9 @@ impl Files {
|
||||
}
|
||||
crate::fd_manager::send_fd_manager_close(&self.our, closed, &self.send_to_loop)
|
||||
.await
|
||||
.map_err(|e| VfsError::Other { error: e.to_string() })?;
|
||||
.map_err(|e| VfsError::Other {
|
||||
error: e.to_string(),
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1028,20 +1034,20 @@ fn join_paths_safely(base: &PathBuf, extension: &str) -> PathBuf {
|
||||
}
|
||||
|
||||
async fn handle_fd_request(km: KernelMessage, files: Files) -> anyhow::Result<()> {
|
||||
let Message::Request(Request {
|
||||
body,
|
||||
..
|
||||
}) = km.message
|
||||
else {
|
||||
let Message::Request(Request { body, .. }) = km.message else {
|
||||
return Err(anyhow::anyhow!("not a request"));
|
||||
};
|
||||
|
||||
let request: FdManagerRequest = serde_json::from_slice(&body)?;
|
||||
|
||||
match request {
|
||||
FdManagerRequest::Cull { cull_fraction_denominator } => {
|
||||
FdManagerRequest::Cull {
|
||||
cull_fraction_denominator,
|
||||
} => {
|
||||
let fraction_to_close = files.open_files.len() as u64 / cull_fraction_denominator;
|
||||
files.close_least_recently_used_files(fraction_to_close).await?;
|
||||
files
|
||||
.close_least_recently_used_files(fraction_to_close)
|
||||
.await?;
|
||||
}
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!("non-Cull FdManagerRequest"));
|
||||
|
Loading…
Reference in New Issue
Block a user