more simpler clippy fixes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-07-28 09:56:03 +02:00
parent 3f7440916f
commit 8e70d421f2
3 changed files with 11 additions and 24 deletions

View File

@ -64,11 +64,9 @@ impl ServerAdapter for StaticAuthAdapter {
Box::new(SimpleUserInformation {});
Ok((String::from("root@pam"), user_info))
}
_ => {
return Err(AuthError::Generic(format_err!(
"invalid file restore ticket provided"
)));
}
_ => Err(AuthError::Generic(format_err!(
"invalid file restore ticket provided"
))),
}
})
}

View File

@ -17,7 +17,7 @@ use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use serde_json::{json, Value};
use tokio_stream::wrappers::ReceiverStream;
use proxmox_http::client::{RateLimitedStream, ShareableRateLimit};
use proxmox_http::client::RateLimitedStream;
use proxmox_lang::try_block;
use proxmox_metrics::MetricsData;
use proxmox_router::{RpcEnvironment, RpcEnvironmentType, UserInformation};
@ -46,7 +46,7 @@ use proxmox_backup::{
jobstate::{self, Job},
},
tools::disks::BlockDevStat,
traffic_control_cache::TRAFFIC_CONTROL_CACHE,
traffic_control_cache::{SharedRateLimit, TRAFFIC_CONTROL_CACHE},
};
use pbs_buildcfg::configdir;
@ -1387,10 +1387,7 @@ async fn run_traffic_control_updater() {
fn lookup_rate_limiter(
peer: std::net::SocketAddr,
) -> (
Option<Arc<dyn ShareableRateLimit>>,
Option<Arc<dyn ShareableRateLimit>>,
) {
) -> (Option<SharedRateLimit>, Option<SharedRateLimit>) {
let mut cache = TRAFFIC_CONTROL_CACHE.lock().unwrap();
let now = proxmox_time::epoch_i64();

View File

@ -20,6 +20,8 @@ use pbs_config::ConfigVersionCache;
use crate::tools::SharedRateLimiter;
pub type SharedRateLimit = Arc<dyn ShareableRateLimit>;
lazy_static::lazy_static! {
/// Shared traffic control cache singleton.
pub static ref TRAFFIC_CONTROL_CACHE: Arc<Mutex<TrafficControlCache>> =
@ -54,13 +56,7 @@ pub struct TrafficControlCache {
last_update: i64,
last_traffic_control_generation: usize,
rules: Vec<ParsedTcRule>,
limiter_map: HashMap<
String,
(
Option<Arc<dyn ShareableRateLimit>>,
Option<Arc<dyn ShareableRateLimit>>,
),
>,
limiter_map: HashMap<String, (Option<SharedRateLimit>, Option<SharedRateLimit>)>,
use_utc: bool, // currently only used for testing
}
@ -115,7 +111,7 @@ fn create_limiter(
name: &str,
rate: u64,
burst: u64,
) -> Result<Arc<dyn ShareableRateLimit>, Error> {
) -> Result<SharedRateLimit, Error> {
if use_shared_memory {
let limiter = SharedRateLimiter::mmap_shmem(name, rate, burst)?;
Ok(Arc::new(limiter))
@ -339,11 +335,7 @@ impl TrafficControlCache {
&self,
peer: SocketAddr,
now: i64,
) -> (
&str,
Option<Arc<dyn ShareableRateLimit>>,
Option<Arc<dyn ShareableRateLimit>>,
) {
) -> (&str, Option<SharedRateLimit>, Option<SharedRateLimit>) {
let peer_ip = cannonical_ip(peer.ip());
log::debug!("lookup_rate_limiter: {:?}", peer_ip);