Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
rm lock
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk committed May 14, 2022
1 parent 1387242 commit 58151e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
24 changes: 12 additions & 12 deletions ethers-solc/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ pub const BERLIN_SOLC: Version = Version::new(0, 8, 5);
/// <https://blog.soliditylang.org/2021/08/11/solidity-0.8.7-release-announcement/>
pub const LONDON_SOLC: Version = Version::new(0, 8, 7);

#[cfg(any(test, feature = "tests"))]
use std::sync::Mutex;
// #[cfg(any(test, feature = "tests"))]
// use std::sync::Mutex;

#[cfg(any(test, feature = "tests"))]
#[allow(unused)]
static LOCK: once_cell::sync::Lazy<Mutex<()>> = once_cell::sync::Lazy::new(|| Mutex::new(()));
// #[cfg(any(test, feature = "tests"))]
// #[allow(unused)]
// static LOCK: once_cell::sync::Lazy<Mutex<()>> = once_cell::sync::Lazy::new(|| Mutex::new(()));

/// take the lock in tests, we use this to enforce that
/// a test does not run while a compiler version is being installed
///
/// This ensures that only one thread installs a missing `solc` exe.
/// Instead of taking this lock in `Solc::blocking_install`, the lock should be taken before
/// installation is detected.
#[cfg(any(test, feature = "tests"))]
#[allow(unused)]
pub(crate) fn take_solc_installer_lock() -> std::sync::MutexGuard<'static, ()> {
LOCK.lock().unwrap()
}
// #[cfg(any(test, feature = "tests"))]
// #[allow(unused)]
// pub(crate) fn take_solc_installer_lock() -> std::sync::MutexGuard<'static, ()> {
// LOCK.lock().unwrap()
// }

/// A list of upstream Solc releases, used to check which version
/// we should download.
Expand Down Expand Up @@ -296,8 +296,8 @@ impl Solc {
/// If the required compiler version is not installed, it also proceeds to install it.
#[cfg(all(feature = "svm-solc"))]
pub fn ensure_installed(sol_version: &VersionReq) -> Result<Version> {
#[cfg(any(test, feature = "tests"))]
let _lock = take_solc_installer_lock();
// #[cfg(any(test, feature = "tests"))]
// let _lock = take_solc_installer_lock();

// load the local / remote versions
let versions = utils::installed_versions(svm::SVM_HOME.as_path()).unwrap_or_default();
Expand Down
12 changes: 4 additions & 8 deletions ethers-solc/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ impl VersionedSources {
use crate::{utils::RuntimeOrHandle, Solc};

// we take the installer lock here to ensure installation checking is done in sync
#[cfg(any(test, feature = "tests"))]
let _lock = crate::compile::take_solc_installer_lock();
// #[cfg(any(test, feature = "tests"))]
// let _lock = crate::compile::take_solc_installer_lock();

let mut sources_by_version = std::collections::BTreeMap::new();
for (version, sources) in self.inner {
Expand All @@ -723,9 +723,7 @@ impl VersionedSources {
// install missing solc
RuntimeOrHandle::new()
.block_on(async { Solc::blocking_install(version.as_ref()) })
.map_err(|e| {
SolcError::msg(format!("error installing solc: {}", e.to_string()))
})?
.map_err(|e| SolcError::msg(format!("error installing solc: {}", e)))?
}
} else {
// find installed svm
Expand All @@ -745,9 +743,7 @@ impl VersionedSources {
tracing::trace!("corrupted solc version, redownloading \"{}\"", version);
RuntimeOrHandle::new()
.block_on(async { Solc::blocking_install(version.as_ref()) })
.map_err(|e| {
SolcError::msg(format!("error installing solc: {}", e.to_string()))
})?;
.map_err(|e| SolcError::msg(format!("error installing solc: {}", e)))?;
tracing::trace!("reinstalled solc: \"{}\"", version);
}
}
Expand Down

0 comments on commit 58151e0

Please sign in to comment.