mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-12 16:21:13 +00:00
shm: Throw RefCountBadAlloc if insufficient space in the ref count segment
This commit is contained in:
parent
961eca5276
commit
f006fd8b78
|
@ -76,6 +76,11 @@ struct MessageBadAlloc : std::runtime_error
|
|||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
struct RefCountBadAlloc : std::runtime_error
|
||||
{
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
} // namespace fair::mq
|
||||
|
||||
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) {
|
||||
// UR msg not yet shared, create the reference counting object with count 2
|
||||
otherMsg.fShared = fRegionPtr->HandleFromAddress(&(fRegionPtr->MakeRefCount(2)));
|
||||
try {
|
||||
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 {
|
||||
fRegionPtr->GetRefCountAddressFromHandle(otherMsg.fShared)->Increment();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user