fix: Always prepend proc name to shared mem prefix

Our shared memory model isn't really designed to be shared across
processes. Maybe some day it will.
This commit is contained in:
John Colvin committed 2025-08-24 13:46:52 -04:00
1 parent 5f80492c93
commit 43df2bbdc5
1 file changed
+6 -2
+6 -2
View File
@@ -15,8 +15,12 @@ std::string ShmSegmentName::prefix() {
std::lock_guard<std::mutex> lock{prefix_mx_};
// Verify it hasn't been initialized again (since the initial check was done without a lock).
if (!prefix_initialized_) {
if (!os::try_expand_env(SHARED_MEMORY_PREFIX, prefix_)) {
prefix_ = os::process_path().filename().string();
os::try_expand_env(SHARED_MEMORY_PREFIX, prefix_);
auto proc_name = os::process_path().filename().string();
if (prefix_.empty()) {
prefix_ = std::move(proc_name);
} else {
prefix_.insert(0, proc_name + "_");
}
}
bts_assert(!prefix_.empty());