summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/headless.rs5
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)