From 2b076c4b17e735b37bdeb65351fededcc54d07ed Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Fri, 20 Sep 2019 17:43:59 -0700 Subject: [PATCH] blackbox: preserve session_id when replacing singleton Summary: The current API replaces `session_id` when the global blackbox switched from in-memory to on-disk. It should preserve the session id. Reviewed By: singhsrb Differential Revision: D17429691 fbshipit-source-id: d37811c3d7622c4f86615c41bce40f4e479eabd2 --- lib/blackbox/src/blackbox.rs | 2 +- lib/blackbox/src/singleton.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/blackbox/src/blackbox.rs b/lib/blackbox/src/blackbox.rs index d8d028281e..031fed63ce 100644 --- a/lib/blackbox/src/blackbox.rs +++ b/lib/blackbox/src/blackbox.rs @@ -26,7 +26,7 @@ pub struct Blackbox { opts: BlackboxOptions, // An ID that can be "grouped by" to figure everything about a session. - session_id: u64, + pub(crate) session_id: u64, // The on-disk files are considered bad (ex. no permissions, or no disk space) // and further write attempts will be ignored. diff --git a/lib/blackbox/src/singleton.rs b/lib/blackbox/src/singleton.rs index 7fbdebe776..fe31a55392 100644 --- a/lib/blackbox/src/singleton.rs +++ b/lib/blackbox/src/singleton.rs @@ -20,6 +20,8 @@ lazy_static! { /// Replace the global [`Blackbox`] instance. /// +/// The session ID of the old blackbox will be reused. +/// /// If [`log`] was called, their side effects will be re-applied to the /// specified blackbox. pub fn init(mut blackbox: Blackbox) { @@ -34,6 +36,7 @@ pub fn init(mut blackbox: Blackbox) { } } } + blackbox.session_id = old_blackbox.session_id; *singleton.deref_mut() = blackbox; }