Skip to content

Commit 8527755

Browse files
committed
Increment SESSION_COUNT when cloning a Session.
Fixes #8166.
1 parent c097ec9 commit 8527755

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

rust/src/headless.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ pub fn license_location() -> Option<LicenseLocation> {
295295
}
296296

297297
/// 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.
298-
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
298+
#[derive(Debug, Default, PartialEq, Eq, Hash)]
299299
pub struct Session {
300300
license_duration: Option<Duration>,
301301
}
@@ -422,6 +422,15 @@ impl Session {
422422
}
423423
}
424424

425+
impl Clone for Session {
426+
fn clone(&self) -> Self {
427+
SESSION_COUNT.fetch_add(1, SeqCst);
428+
Self {
429+
license_duration: self.license_duration,
430+
}
431+
}
432+
}
433+
425434
impl Drop for Session {
426435
fn drop(&mut self) {
427436
let previous_count = SESSION_COUNT.fetch_sub(1, SeqCst);

0 commit comments

Comments
 (0)