mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Make shmid an 8-digit hex number
This commit is contained in:
parent
afe2dcaa02
commit
6dd0a44308
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||||
#include <boost/interprocess/allocators/allocator.hpp>
|
#include <boost/interprocess/allocators/allocator.hpp>
|
||||||
|
@ -113,8 +112,11 @@ struct RegionBlock
|
||||||
inline std::string buildShmIdFromSessionIdAndUserId(const std::string& sessionId)
|
inline std::string buildShmIdFromSessionIdAndUserId(const std::string& sessionId)
|
||||||
{
|
{
|
||||||
std::string seed((std::to_string(geteuid()) + sessionId));
|
std::string seed((std::to_string(geteuid()) + sessionId));
|
||||||
std::string shmId = picosha2::hash256_hex_string(seed);
|
// generate a 8-digit hex value out of sha256 hash
|
||||||
shmId.resize(10, '_');
|
std::vector<unsigned char> hash(4);
|
||||||
|
picosha2::hash256(seed.begin(), seed.end(), hash.begin(), hash.end());
|
||||||
|
std::string shmId = picosha2::bytes_to_hex_string(hash.begin(), hash.end());
|
||||||
|
|
||||||
return shmId;
|
return shmId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class TransportFactory final : public fair::mq::TransportFactory
|
||||||
|
|
||||||
int numIoThreads = 1;
|
int numIoThreads = 1;
|
||||||
std::string sessionName = "default";
|
std::string sessionName = "default";
|
||||||
size_t segmentSize = 2000000000;
|
size_t segmentSize = 2ULL << 30;
|
||||||
bool autolaunchMonitor = false;
|
bool autolaunchMonitor = false;
|
||||||
bool throwOnBadAlloc = true;
|
bool throwOnBadAlloc = true;
|
||||||
if (config) {
|
if (config) {
|
||||||
|
@ -71,6 +71,7 @@ class TransportFactory final : public fair::mq::TransportFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
fShmId = buildShmIdFromSessionIdAndUserId(sessionName);
|
fShmId = buildShmIdFromSessionIdAndUserId(sessionName);
|
||||||
|
LOG(debug) << "Generated shmid '" << fShmId << "' out of session id '" << sessionName << "'.";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (zmq_ctx_set(fZMQContext, ZMQ_IO_THREADS, numIoThreads) != 0) {
|
if (zmq_ctx_set(fZMQContext, ZMQ_IO_THREADS, numIoThreads) != 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user