From 18dde29a06847598d97a5166e3badb14a779c001 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Fri, 31 Jan 2025 13:09:15 -0500 Subject: Add lock on enterprise checkout code in Rust API This is being done as a preventative measure against possible races in checkout code. This is more so just peace of mind, the enterprise code that is touched in this function only locks on a single mutex so this is probably useless, but I would rather have this assurance than have to debug some issue in this code. --- rust/src/enterprise.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'rust/src') diff --git a/rust/src/enterprise.rs b/rust/src/enterprise.rs index 34fa8a03..aecbf974 100644 --- a/rust/src/enterprise.rs +++ b/rust/src/enterprise.rs @@ -25,6 +25,10 @@ pub fn checkout_license(duration: Duration) -> Result<(), EnterpriseCheckoutErro return Ok(()); } + // The disparate core functions we call here might already have mutexes to guard. + static CHECKOUT_MUTEX: std::sync::Mutex<()> = std::sync::Mutex::new(()); + let _mtx = CHECKOUT_MUTEX.lock().unwrap(); + #[allow(clippy::collapsible_if)] if !is_server_initialized() { // We need to first initialize the server. -- cgit v1.3.1