fix, RwLock, remove nested read calls

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-09-17 13:01:27 +08:00
parent a1e1f5aab6
commit ae3efa1151
4 changed files with 69 additions and 87 deletions

View File

@@ -1042,24 +1042,6 @@ pub async fn get_key(sync: bool) -> String {
key
}
pub fn is_peer_version_ge(v: &str) -> bool {
#[cfg(not(any(feature = "flutter", feature = "cli")))]
if let Some(session) = crate::ui::CUR_SESSION.lock().unwrap().as_ref() {
return session.get_peer_version() >= hbb_common::get_version_number(v);
}
#[cfg(feature = "flutter")]
if let Some(session) = crate::flutter::SESSIONS
.read()
.unwrap()
.get(&*crate::flutter::CUR_SESSION_ID.read().unwrap())
{
return session.get_peer_version() >= hbb_common::get_version_number(v);
}
false
}
pub fn pk_to_fingerprint(pk: Vec<u8>) -> String {
let s: String = pk.iter().map(|u| format!("{:02x}", u)).collect();
s.chars()