mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
shm: hide picosha2 from header
This commit is contained in:
committed by
Dennis Klein
parent
08ba068791
commit
9f9583eb55
48
fairmq/shmem/Common.cxx
Normal file
48
fairmq/shmem/Common.cxx
Normal file
@@ -0,0 +1,48 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <picosha2.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace fair::mq::shmem
|
||||
{
|
||||
|
||||
std::string makeShmIdStr(const std::string& sessionId, const std::string& userId)
|
||||
{
|
||||
std::string seed(userId + sessionId);
|
||||
// generate a 8-digit hex value out of sha256 hash
|
||||
std::vector<unsigned char> hash(4);
|
||||
picosha2::hash256(seed.begin(), seed.end(), hash.begin(), hash.end());
|
||||
|
||||
return picosha2::bytes_to_hex_string(hash.begin(), hash.end());
|
||||
}
|
||||
|
||||
std::string makeShmIdStr(const std::string& sessionId)
|
||||
{
|
||||
return makeShmIdStr(sessionId, std::to_string(geteuid()));
|
||||
}
|
||||
|
||||
uint64_t makeShmIdUint64(const std::string& sessionId)
|
||||
{
|
||||
std::string shmId = makeShmIdStr(sessionId);
|
||||
uint64_t id = 0;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << shmId;
|
||||
ss >> id;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
} // namespace fair::mq::shmem
|
@@ -8,10 +8,7 @@
|
||||
#ifndef FAIR_MQ_SHMEM_COMMON_H_
|
||||
#define FAIR_MQ_SHMEM_COMMON_H_
|
||||
|
||||
#include <picosha2.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <functional> // std::equal_to
|
||||
|
||||
@@ -26,7 +23,6 @@
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace fair::mq::shmem
|
||||
@@ -212,31 +208,9 @@ struct RegionBlock
|
||||
|
||||
// find id for unique shmem name:
|
||||
// a hash of user id + session id, truncated to 8 characters (to accommodate for name size limit on some systems (MacOS)).
|
||||
inline std::string makeShmIdStr(const std::string& sessionId, const std::string& userId)
|
||||
{
|
||||
std::string seed(userId + sessionId);
|
||||
// generate a 8-digit hex value out of sha256 hash
|
||||
std::vector<unsigned char> hash(4);
|
||||
picosha2::hash256(seed.begin(), seed.end(), hash.begin(), hash.end());
|
||||
|
||||
return picosha2::bytes_to_hex_string(hash.begin(), hash.end());
|
||||
}
|
||||
|
||||
inline std::string makeShmIdStr(const std::string& sessionId)
|
||||
{
|
||||
return makeShmIdStr(sessionId, std::to_string(geteuid()));
|
||||
}
|
||||
|
||||
inline uint64_t makeShmIdUint64(const std::string& sessionId)
|
||||
{
|
||||
std::string shmId = makeShmIdStr(sessionId);
|
||||
uint64_t id = 0;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << shmId;
|
||||
ss >> id;
|
||||
|
||||
return id;
|
||||
}
|
||||
std::string makeShmIdStr(const std::string& sessionId, const std::string& userId);
|
||||
std::string makeShmIdStr(const std::string& sessionId);
|
||||
uint64_t makeShmIdUint64(const std::string& sessionId);
|
||||
|
||||
struct SegmentSize : public boost::static_visitor<size_t>
|
||||
{
|
||||
|
Reference in New Issue
Block a user