summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-01-31 13:09:15 -0500
committerMason Reed <mason@vector35.com>2025-01-31 16:17:30 -0500
commit18dde29a06847598d97a5166e3badb14a779c001 (patch)
treef6e3f441b947485a58de62e759237a904a816b99
parentd0379d3139a3d60351a49425469d7672f69542ad (diff)
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.
-rw-r--r--rust/src/enterprise.rs4
1 files changed, 4 insertions, 0 deletions
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.