diff options
| author | Mason Reed <mason@vector35.com> | 2025-02-07 00:03:26 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-02-07 00:03:26 -0500 |
| commit | ce77933297d0e1a9a89c7eab7b8fdd39eb5712e1 (patch) | |
| tree | 52214757552ff7d74178c93d31f9fdd34bf9c11b /rust/src | |
| parent | 47ef9cd42471dbc4ff85affb3f6747778562a547 (diff) | |
Move session registration for Rust headless initialization to be immediate
This fixes a possible race if another thread can successfully shutdown before the current thread can register its session
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/headless.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/rust/src/headless.rs b/rust/src/headless.rs index 2cc87056..3eb6ee57 100644 --- a/rust/src/headless.rs +++ b/rust/src/headless.rs @@ -302,8 +302,11 @@ impl Session { pub fn new() -> Result<Self, InitializationError> { if license_location().is_some() { // We were able to locate a license, continue with initialization. + // Grab the session before initialization to prevent another thread from initializing + // and shutting down before this thread can increment the SESSION_COUNT. + let session = Self::registered_session(); init()?; - Ok(Self::registered_session()) + Ok(session) } else { // There was no license that could be automatically retrieved, you must call [Self::new_with_license]. Err(InitializationError::NoLicenseFound) |
