Merge pull request #1900 from 64kramsystem/fix_locks_not_acquired

hbb_common: Fix CONFIG locks unintentionally not acquired
This commit is contained in:
RustDesk 2022-11-01 23:24:43 +08:00 committed by GitHub
commit 789130e93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -795,7 +795,7 @@ const PEERS: &str = "peers";
impl PeerConfig {
pub fn load(id: &str) -> PeerConfig {
let _ = CONFIG.read().unwrap(); // for lock
let _lock = CONFIG.read().unwrap();
match confy::load_path(&Self::path(id)) {
Ok(config) => {
let mut config: PeerConfig = config;
@ -827,7 +827,7 @@ impl PeerConfig {
}
pub fn store(&self, id: &str) {
let _ = CONFIG.read().unwrap(); // for lock
let _lock = CONFIG.read().unwrap();
let mut config = self.clone();
config.password = encrypt_vec_or_original(&config.password, PASSWORD_ENC_VERSION);
config
@ -999,7 +999,7 @@ pub struct LanPeers {
impl LanPeers {
pub fn load() -> LanPeers {
let _ = CONFIG.read().unwrap(); // for lock
let _lock = CONFIG.read().unwrap();
match confy::load_path(&Config::file_("_lan_peers")) {
Ok(peers) => peers,
Err(err) => {