From 8527755f90c4516f3b240f4ba8a9a9e5462d6ed3 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Tue, 12 May 2026 18:37:26 -0400 Subject: [PATCH] Increment SESSION_COUNT when cloning a Session. Fixes #8166. --- rust/src/headless.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rust/src/headless.rs b/rust/src/headless.rs index fce8fbe773..f37259fd79 100644 --- a/rust/src/headless.rs +++ b/rust/src/headless.rs @@ -295,7 +295,7 @@ pub fn license_location() -> Option { } /// 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. -#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Default, PartialEq, Eq, Hash)] pub struct Session { license_duration: Option, } @@ -422,6 +422,15 @@ impl Session { } } +impl Clone for Session { + fn clone(&self) -> Self { + SESSION_COUNT.fetch_add(1, SeqCst); + Self { + license_duration: self.license_duration, + } + } +} + impl Drop for Session { fn drop(&mut self) { let previous_count = SESSION_COUNT.fetch_sub(1, SeqCst);