You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if !enterprise::is_server_initialized() && !enterprise::initialize_server(){
285
+
returnNone;
286
+
}
287
+
// If Enterprise thinks we are using a floating license, then report it will be in the keychain
288
+
if enterprise::is_server_floating_license(){
289
+
Some(LicenseLocation::Keychain)
290
+
}else{
291
+
None
292
+
}
293
+
}else{
294
+
None
278
295
}
279
296
}
280
297
}
281
298
}
282
299
}
283
300
284
301
/// Wrapper for [`init`] and [`shutdown`]. Instantiating this at the top of your script will initialize everything correctly and then clean itself up at exit as well.
285
-
pubstructSession{}
302
+
pubstructSession{
303
+
index:usize,
304
+
}
286
305
287
306
implSession{
288
307
/// Get a registered [`Session`] for use.
289
308
///
290
309
/// This is required so that we can keep track of the [`SESSION_COUNT`].
291
310
fnregistered_session() -> Self{
292
-
let _previous_count = SESSION_COUNT.fetch_add(1,SeqCst);
293
-
Self{}
311
+
let previous_count = SESSION_COUNT.fetch_add(1,SeqCst);
312
+
Self{
313
+
index: previous_count,
314
+
}
294
315
}
295
316
296
317
/// Before calling new you must make sure that the license is retrievable, otherwise the core won't be able to initialize.
@@ -302,8 +323,12 @@ impl Session {
302
323
// We were able to locate a license, continue with initialization.
303
324
// Grab the session before initialization to prevent another thread from initializing
304
325
// and shutting down before this thread can increment the SESSION_COUNT.
326
+
let lock = INIT_LOCK.lock().map_err(|_| InitializationError::Mutex)?;
305
327
let session = Self::registered_session();
306
-
init()?;
328
+
if session.index == 0{
329
+
init()?;
330
+
}
331
+
drop(lock);
307
332
Ok(session)
308
333
}else{
309
334
// There was no license that could be automatically retrieved, you must call [Self::new_with_license].
@@ -316,8 +341,13 @@ impl Session {
316
341
/// This differs from [`Session::new`] in that it does not check to see if there is a license that the core
317
342
/// can discover by itself, therefor it is expected that you know where your license is when calling this directly.
0 commit comments