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:
1 parent
48ae662fca
commit
8356d3e394
1 file changed
+7
-3
@@ -1,6 +1,6 @@
|
||||
#include "ShmSegmentName.h"
|
||||
#include "spark/utils/bts_assert.h"
|
||||
#include "spark/os/os.h"
|
||||
#include "spark/utils/bts_assert.h"
|
||||
|
||||
namespace bts::md {
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user