mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Check transport type of msg and corresponding region
This commit is contained in:
parent
9defa71622
commit
c6a6a5f21b
|
@ -109,12 +109,17 @@ class Message final : public fair::mq::Message
|
||||||
, fRegionPtr(nullptr)
|
, fRegionPtr(nullptr)
|
||||||
, fLocalPtr(static_cast<char*>(data))
|
, fLocalPtr(static_cast<char*>(data))
|
||||||
{
|
{
|
||||||
|
if (region->GetType() != GetType()) {
|
||||||
|
LOG(error) << "region type (" << region->GetType() << ") does not match message type (" << GetType() << ")";
|
||||||
|
throw TransportError(tools::ToString("region type (", region->GetType(), ") does not match message type (", GetType(), ")"));
|
||||||
|
}
|
||||||
|
|
||||||
if (reinterpret_cast<const char*>(data) >= reinterpret_cast<const char*>(region->GetData()) &&
|
if (reinterpret_cast<const char*>(data) >= reinterpret_cast<const char*>(region->GetData()) &&
|
||||||
reinterpret_cast<const char*>(data) <= reinterpret_cast<const char*>(region->GetData()) + region->GetSize()) {
|
reinterpret_cast<const char*>(data) <= reinterpret_cast<const char*>(region->GetData()) + region->GetSize()) {
|
||||||
fMeta.fHandle = (boost::interprocess::managed_shared_memory::handle_t)(reinterpret_cast<const char*>(data) - reinterpret_cast<const char*>(region->GetData()));
|
fMeta.fHandle = (boost::interprocess::managed_shared_memory::handle_t)(reinterpret_cast<const char*>(data) - reinterpret_cast<const char*>(region->GetData()));
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "trying to create region message with data from outside the region";
|
LOG(error) << "trying to create region message with data from outside the region";
|
||||||
throw std::runtime_error("trying to create region message with data from outside the region");
|
throw TransportError("trying to create region message with data from outside the region");
|
||||||
}
|
}
|
||||||
fManager.IncrementMsgCounter();
|
fManager.IncrementMsgCounter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,11 @@ class Message final : public fair::mq::Message
|
||||||
, fAlignment(0)
|
, fAlignment(0)
|
||||||
, fMsg(std::make_unique<zmq_msg_t>())
|
, fMsg(std::make_unique<zmq_msg_t>())
|
||||||
{
|
{
|
||||||
|
if (region->GetType() != GetType()) {
|
||||||
|
LOG(error) << "region type (" << region->GetType() << ") does not match message type (" << GetType() << ")";
|
||||||
|
throw TransportError(tools::ToString("region type (", region->GetType(), ") does not match message type (", GetType(), ")"));
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: make this zero-copy:
|
// FIXME: make this zero-copy:
|
||||||
// simply taking over the provided buffer can casue premature delete, since region could be
|
// simply taking over the provided buffer can casue premature delete, since region could be
|
||||||
// destroyed before the message is sent out. Needs lifetime extension for the ZMQ region.
|
// destroyed before the message is sent out. Needs lifetime extension for the ZMQ region.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user