blackbox: do not inherit session_id if pid has changed

Summary:
D17429691 made blackbox reuse session_id unconditionally. That has an
undesirable side effect that chg processes are all logged as a same session id.
Fix that by detecting pid change and avoid reusing session_id in that case.

Reviewed By: singhsrb

Differential Revision: D17532555

fbshipit-source-id: cf11bb66f7d7242429b90ab5e5ea85ca307f92c3
This commit is contained in:
Jun Wu 2019-09-25 17:16:00 -07:00 committed by Facebook Github Bot
parent 7db4a13b5f
commit ab3da9107c
2 changed files with 10 additions and 1 deletions

View File

@ -175,6 +175,11 @@ impl Blackbox {
}
}
/// Get the pid stored in session_id.
pub(crate) fn session_pid(&self) -> u32 {
(self.session_id & 0xffffff) as u32
}
pub fn session_id(&self) -> u64 {
self.session_id
}

View File

@ -36,7 +36,11 @@ pub fn init(mut blackbox: Blackbox) {
}
}
}
blackbox.session_id = old_blackbox.session_id;
// Perserve session_id if pid hasn't been changed.
if blackbox.session_pid() == old_blackbox.session_pid() {
blackbox.session_id = old_blackbox.session_id;
}
*singleton.deref_mut() = blackbox;
}