mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
shm: Throw RefCountBadAlloc if insufficient space in the ref count segment
This commit is contained in:
parent
961eca5276
commit
424e22b41a
|
@ -76,6 +76,11 @@ struct MessageBadAlloc : std::runtime_error
|
||||||
using std::runtime_error::runtime_error;
|
using std::runtime_error::runtime_error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RefCountBadAlloc : std::runtime_error
|
||||||
|
{
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace fair::mq
|
} // namespace fair::mq
|
||||||
|
|
||||||
using fairmq_free_fn [[deprecated("Use fair::mq::FreeFn")]] = fair::mq::FreeFn;
|
using fairmq_free_fn [[deprecated("Use fair::mq::FreeFn")]] = fair::mq::FreeFn;
|
||||||
|
|
|
@ -279,7 +279,15 @@ class Message final : public fair::mq::Message
|
||||||
}
|
}
|
||||||
if (otherMsg.fShared < 0) {
|
if (otherMsg.fShared < 0) {
|
||||||
// UR msg not yet shared, create the reference counting object with count 2
|
// UR msg not yet shared, create the reference counting object with count 2
|
||||||
|
try {
|
||||||
otherMsg.fShared = fRegionPtr->HandleFromAddress(&(fRegionPtr->MakeRefCount(2)));
|
otherMsg.fShared = fRegionPtr->HandleFromAddress(&(fRegionPtr->MakeRefCount(2)));
|
||||||
|
} catch (boost::interprocess::bad_alloc& ba) {
|
||||||
|
throw RefCountBadAlloc(tools::ToString(
|
||||||
|
"Insufficient space in the reference count segment ",
|
||||||
|
otherMsg.fRegionId,
|
||||||
|
", original exception: bad_alloc: ",
|
||||||
|
ba.what()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fRegionPtr->GetRefCountAddressFromHandle(otherMsg.fShared)->Increment();
|
fRegionPtr->GetRefCountAddressFromHandle(otherMsg.fShared)->Increment();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user