mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Fix shmem::Message::SetUsedSize(0)
This commit is contained in:
parent
c5487a11ed
commit
c6b13cd3a1
|
@ -206,6 +206,9 @@ class Message final : public fair::mq::Message
|
||||||
{
|
{
|
||||||
if (newSize == fMeta.fSize) {
|
if (newSize == fMeta.fSize) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (newSize == 0) {
|
||||||
|
Deallocate();
|
||||||
|
return true;
|
||||||
} else if (newSize <= fMeta.fSize) {
|
} else if (newSize <= fMeta.fSize) {
|
||||||
try {
|
try {
|
||||||
fLocalPtr = fManager.ShrinkInPlace(newSize, fLocalPtr, fMeta.fSegmentId);
|
fLocalPtr = fManager.ShrinkInPlace(newSize, fLocalPtr, fMeta.fSegmentId);
|
||||||
|
@ -268,7 +271,7 @@ class Message final : public fair::mq::Message
|
||||||
return fLocalPtr;
|
return fLocalPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseMessage()
|
void Deallocate()
|
||||||
{
|
{
|
||||||
if (fMeta.fHandle >= 0 && !fQueued) {
|
if (fMeta.fHandle >= 0 && !fQueued) {
|
||||||
if (fMeta.fRegionId == 0) {
|
if (fMeta.fRegionId == 0) {
|
||||||
|
@ -289,6 +292,11 @@ class Message final : public fair::mq::Message
|
||||||
}
|
}
|
||||||
fLocalPtr = nullptr;
|
fLocalPtr = nullptr;
|
||||||
fMeta.fSize = 0;
|
fMeta.fSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseMessage()
|
||||||
|
{
|
||||||
|
Deallocate();
|
||||||
fAlignment = 0;
|
fAlignment = 0;
|
||||||
|
|
||||||
fManager.DecrementMsgCounter(); // TODO: put this to debug mode
|
fManager.DecrementMsgCounter(); // TODO: put this to debug mode
|
||||||
|
|
|
@ -39,6 +39,7 @@ void RunPushPullWithMsgResize(const string& transport, const string& _address)
|
||||||
FairMQChannel pull{"Pull", "pull", factory};
|
FairMQChannel pull{"Pull", "pull", factory};
|
||||||
pull.Connect(address);
|
pull.Connect(address);
|
||||||
|
|
||||||
|
{
|
||||||
FairMQMessagePtr outMsg(push.NewMessage(1000));
|
FairMQMessagePtr outMsg(push.NewMessage(1000));
|
||||||
ASSERT_EQ(outMsg->GetSize(), 1000);
|
ASSERT_EQ(outMsg->GetSize(), 1000);
|
||||||
memcpy(outMsg->GetData(), "ABC", 3);
|
memcpy(outMsg->GetData(), "ABC", 3);
|
||||||
|
@ -67,6 +68,20 @@ void RunPushPullWithMsgResize(const string& transport, const string& _address)
|
||||||
ASSERT_EQ(static_cast<char*>(inMsg->GetData())[0], 'A');
|
ASSERT_EQ(static_cast<char*>(inMsg->GetData())[0], 'A');
|
||||||
ASSERT_EQ(static_cast<char*>(inMsg->GetData())[1], 'B');
|
ASSERT_EQ(static_cast<char*>(inMsg->GetData())[1], 'B');
|
||||||
ASSERT_EQ(static_cast<char*>(inMsg->GetData())[2], 'C');
|
ASSERT_EQ(static_cast<char*>(inMsg->GetData())[2], 'C');
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FairMQMessagePtr outMsg(push.NewMessage(1000));
|
||||||
|
ASSERT_EQ(outMsg->SetUsedSize(0), true);
|
||||||
|
ASSERT_EQ(outMsg->GetSize(), 0);
|
||||||
|
FairMQMessagePtr msgCopy(push.NewMessage());
|
||||||
|
msgCopy->Copy(*outMsg);
|
||||||
|
ASSERT_EQ(msgCopy->GetSize(), 0);
|
||||||
|
ASSERT_EQ(push.Send(outMsg), 0);
|
||||||
|
FairMQMessagePtr inMsg(pull.NewMessage());
|
||||||
|
ASSERT_EQ(pull.Receive(inMsg), 0);
|
||||||
|
ASSERT_EQ(inMsg->GetSize(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunMsgRebuild(const string& transport)
|
void RunMsgRebuild(const string& transport)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user