mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-26 05:31:36 +00:00
fix(shmem): wake the region ack sender when acks stop
- the ack sender waited up to 500 ms for a full ack batch, also after StopAcks(), so each region destruction took at least 500 ms - wait with a predicate that includes the stop flag - set the stop flag under the ack mutex, so that the sender cannot miss the notification Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -205,10 +205,9 @@ struct UnmanagedRegion
|
|||||||
~UnmanagedRegion()
|
~UnmanagedRegion()
|
||||||
{
|
{
|
||||||
LOG(debug) << "~UnmanagedRegion(): " << fName << " (" << (fControlling ? "controller" : "viewer") << ")";
|
LOG(debug) << "~UnmanagedRegion(): " << fName << " (" << (fControlling ? "controller" : "viewer") << ")";
|
||||||
fStopAcks = true;
|
SetStopAcks();
|
||||||
|
|
||||||
if (fAcksSender.joinable()) {
|
if (fAcksSender.joinable()) {
|
||||||
fBlockSendCV.notify_one();
|
|
||||||
fAcksSender.join();
|
fAcksSender.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,10 +356,8 @@ struct UnmanagedRegion
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fBlockMtx);
|
std::unique_lock<std::mutex> lock(fBlockMtx);
|
||||||
|
|
||||||
// try to get <fAckBunchSize> blocks
|
// try to get <fAckBunchSize> blocks, but do not wait when stopping
|
||||||
if (fBlocksToFree.size() < fAckBunchSize) {
|
fBlockSendCV.wait_for(lock, std::chrono::milliseconds(500), [&] { return fBlocksToFree.size() >= fAckBunchSize || fStopAcks; });
|
||||||
fBlockSendCV.wait_for(lock, std::chrono::milliseconds(500));
|
|
||||||
}
|
|
||||||
|
|
||||||
// send whatever blocks we have
|
// send whatever blocks we have
|
||||||
blocksToSend = std::min(fBlocksToFree.size(), fAckBunchSize);
|
blocksToSend = std::min(fBlocksToFree.size(), fAckBunchSize);
|
||||||
@@ -445,12 +442,21 @@ struct UnmanagedRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetStopAcks()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
// set under the lock, so that the ack sender cannot miss the notification
|
||||||
|
std::lock_guard<std::mutex> lock(fBlockMtx);
|
||||||
|
fStopAcks = true;
|
||||||
|
}
|
||||||
|
fBlockSendCV.notify_one();
|
||||||
|
}
|
||||||
|
|
||||||
void StopAcks()
|
void StopAcks()
|
||||||
{
|
{
|
||||||
fStopAcks = true;
|
SetStopAcks();
|
||||||
|
|
||||||
if (fAcksSender.joinable()) {
|
if (fAcksSender.joinable()) {
|
||||||
fBlockSendCV.notify_one();
|
|
||||||
fAcksSender.join();
|
fAcksSender.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user