Skip to content

Commit 18dde29

Browse files
committed
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.
1 parent d0379d3 commit 18dde29

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rust/src/enterprise.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ pub fn checkout_license(duration: Duration) -> Result<(), EnterpriseCheckoutErro
2525
return Ok(());
2626
}
2727

28+
// The disparate core functions we call here might already have mutexes to guard.
29+
static CHECKOUT_MUTEX: std::sync::Mutex<()> = std::sync::Mutex::new(());
30+
let _mtx = CHECKOUT_MUTEX.lock().unwrap();
31+
2832
#[allow(clippy::collapsible_if)]
2933
if !is_server_initialized() {
3034
// We need to first initialize the server.

0 commit comments

Comments
 (0)