mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-14 09:06:47 +00:00
Add safety check in shmem region location
This commit is contained in:
parent
040931fba7
commit
160ee9d064
|
@ -31,10 +31,12 @@ SENDER="fairmq-ex-readout-sender"
|
||||||
SENDER+=" --id sender1"
|
SENDER+=" --id sender1"
|
||||||
SENDER+=" --input-name ps"
|
SENDER+=" --input-name ps"
|
||||||
SENDER+=" --channel-config name=ps,type=pair,method=bind,address=tcp://localhost:7779,transport=shmem"
|
SENDER+=" --channel-config name=ps,type=pair,method=bind,address=tcp://localhost:7779,transport=shmem"
|
||||||
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7780,transport=ofi"
|
#SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7780,transport=ofi"
|
||||||
|
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7780,transport=zeromq"
|
||||||
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
||||||
|
|
||||||
RECEIVER="fairmq-ex-readout-receiver"
|
RECEIVER="fairmq-ex-readout-receiver"
|
||||||
RECEIVER+=" --id receiver1"
|
RECEIVER+=" --id receiver1"
|
||||||
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7780,transport=ofi"
|
#RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7780,transport=ofi"
|
||||||
|
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7780,transport=zeromq"
|
||||||
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
||||||
|
|
|
@ -25,10 +25,12 @@ SENDER="fairmq-ex-readout-sender"
|
||||||
SENDER+=" --id sender1"
|
SENDER+=" --id sender1"
|
||||||
SENDER+=" --input-name bs"
|
SENDER+=" --input-name bs"
|
||||||
SENDER+=" --channel-config name=bs,type=pair,method=bind,address=tcp://localhost:7778,transport=shmem"
|
SENDER+=" --channel-config name=bs,type=pair,method=bind,address=tcp://localhost:7778,transport=shmem"
|
||||||
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7779,transport=ofi"
|
# SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7779,transport=ofi"
|
||||||
|
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7779,transport=zeromq"
|
||||||
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
||||||
|
|
||||||
RECEIVER="fairmq-ex-readout-receiver"
|
RECEIVER="fairmq-ex-readout-receiver"
|
||||||
RECEIVER+=" --id receiver1"
|
RECEIVER+=" --id receiver1"
|
||||||
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7779,transport=ofi"
|
# RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7779,transport=ofi"
|
||||||
|
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7779,transport=zeromq"
|
||||||
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
||||||
|
|
|
@ -132,9 +132,10 @@ bipc::mapped_region* Manager::CreateRegion(const size_t size, const uint64_t id,
|
||||||
{
|
{
|
||||||
bipc::scoped_lock<bipc::named_mutex> lock(fShmMtx);
|
bipc::scoped_lock<bipc::named_mutex> lock(fShmMtx);
|
||||||
VoidAlloc voidAlloc(fManagementSegment.get_segment_manager());
|
VoidAlloc voidAlloc(fManagementSegment.get_segment_manager());
|
||||||
Uint64RegionInfoMap* m = fManagementSegment.find_or_construct<Uint64RegionInfoMap>(bipc::unique_instance)(voidAlloc);
|
Uint64RegionInfoMap* infoMap = fManagementSegment.find_or_construct<Uint64RegionInfoMap>(bipc::unique_instance)(voidAlloc);
|
||||||
m->emplace(id, RegionInfo(path.c_str(), flags, voidAlloc));
|
infoMap->emplace(id, RegionInfo(path.c_str(), flags, voidAlloc));
|
||||||
}
|
}
|
||||||
|
// LOG(debug) << "Created region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'";
|
||||||
|
|
||||||
auto r = fRegions.emplace(id, fair::mq::tools::make_unique<Region>(*this, id, size, false, callback, path, flags));
|
auto r = fRegions.emplace(id, fair::mq::tools::make_unique<Region>(*this, id, size, false, callback, path, flags));
|
||||||
|
|
||||||
|
@ -158,13 +159,16 @@ Region* Manager::GetRemoteRegion(const uint64_t id)
|
||||||
// get region info
|
// get region info
|
||||||
{
|
{
|
||||||
bipc::scoped_lock<bipc::named_mutex> lock(fShmMtx);
|
bipc::scoped_lock<bipc::named_mutex> lock(fShmMtx);
|
||||||
VoidAlloc voidAlloc(fSegment.get_segment_manager());
|
Uint64RegionInfoMap* infoMap = fManagementSegment.find<Uint64RegionInfoMap>(bipc::unique_instance).first;
|
||||||
Uint64RegionInfoMap* m = fManagementSegment.find<Uint64RegionInfoMap>(bipc::unique_instance).first;
|
if (infoMap == nullptr) {
|
||||||
RegionInfo ri = m->at(id);
|
LOG(error) << "Unable to locate the region info";
|
||||||
path = ri.fPath.c_str();
|
throw SharedMemoryError("Unable to locate remote region info");
|
||||||
flags = ri.fFlags;
|
|
||||||
// LOG(debug) << "path: " << path << ", flags: " << flags;
|
|
||||||
}
|
}
|
||||||
|
RegionInfo regionInfo = infoMap->at(id);
|
||||||
|
path = regionInfo.fPath.c_str();
|
||||||
|
flags = regionInfo.fFlags;
|
||||||
|
}
|
||||||
|
// LOG(debug) << "Located remote region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'";
|
||||||
|
|
||||||
auto r = fRegions.emplace(id, fair::mq::tools::make_unique<Region>(*this, id, 0, true, nullptr, path, flags));
|
auto r = fRegions.emplace(id, fair::mq::tools::make_unique<Region>(*this, id, 0, true, nullptr, path, flags));
|
||||||
return r.first->second.get();
|
return r.first->second.get();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace fair
|
namespace fair
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,8 @@ namespace mq
|
||||||
namespace shmem
|
namespace shmem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct SharedMemoryError : std::runtime_error { using std::runtime_error::runtime_error; };
|
||||||
|
|
||||||
class Manager
|
class Manager
|
||||||
{
|
{
|
||||||
friend struct Region;
|
friend struct Region;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user