mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-13 08:36:54 +00:00
fix: address correctness, safety, and concurrency issues (#2327)
Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -28,10 +28,7 @@ static HELP_CACHE: OnceLock<Mutex<HashMap<String, &'static str>>> = OnceLock::ne
|
||||
|
||||
fn intern_string(cache: &OnceLock<Mutex<HashMap<String, &'static str>>>, value: &str) -> &'static str {
|
||||
let cache = cache.get_or_init(Default::default);
|
||||
let mut cache = match cache.lock() {
|
||||
Ok(guard) => guard,
|
||||
Err(poisoned) => poisoned.into_inner(),
|
||||
};
|
||||
let mut cache = cache.lock().unwrap_or_else(|poisoned| poisoned.into_inner());
|
||||
|
||||
if let Some(existing) = cache.get(value) {
|
||||
existing
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::info;
|
||||
|
||||
/// Initializes the global metrics system. This should be called once at the start of the application.
|
||||
/// The provided `CancellationToken` will be used to gracefully shut down the metrics system when needed.
|
||||
@@ -33,7 +34,7 @@ use tokio_util::sync::CancellationToken;
|
||||
/// ```
|
||||
/// Note: This function should only be called once during the application's lifecycle. Calling it multiple times may lead to unexpected behavior.
|
||||
pub fn init_metrics_system(token: CancellationToken) {
|
||||
tracing::info!("init metrics system start");
|
||||
info!("init metrics system start");
|
||||
crate::collectors::init_metrics_collectors(token);
|
||||
tracing::info!("init metrics system done");
|
||||
info!("init metrics system done");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user