Closed simatic closed 6 months ago
Here is an idea of a proper solution.
Create a new instance variable in AlgoLayer
: std::vector<std::thread::id>threadsRegisteredForFullBatchCtrl;
Create AlgoLayer::registerThreadForFullBatchCtrl()
which contains:
threadsRegisteredForFullBatchCtrl.push_back(std::this_thread::get_id());
condVarBatchCtrl.wait(lck, [this] {
return (msgsWaitingToBeBroadcast.size() * getSession()->getParam().getSizeMsg() < getSession()->getParam().getMaxBatchSize())
|| (shortcutBatchCtrl && std::ranges::find(threadsRegisteredForFullBatchCtrl, [elem](std::this_thread::get_id())) != threadsRegisteredForFullBatchCtrl.end()));
});
When a participant calls
BBOBB::totalOrderBroadcast()
, to respect-m
argument (i.e. Maximum size of batch of messages), we execute the following condition:The
|| shortcutBatchCtrl
prevents a call toBBOBB::totalOrderBroadcast()
triggered by a call toSession::callbackDeliver()
to get blocked (inducing a deadlock) by size of batch of messages limit.This way of doing is imperfect, as while
shortcutBatchCtrl
istrue
, a call toBBOBB::totalOrderBroadcast()
triggered from aSession
thread (e.g.Session::sendPeriodicPerfMessage()
) will pass the condition despitemsgsWaitingToBeBroadcast.size() * getSession()->getParam().getSizeMsg() < getSession()->getParam().getMaxBatchSize()
is false.==> Find a proper solution.