mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 13:08:20 +00:00
Improve processing of broker data store responses
Now retrieves and processes all N available responses at once instead of one-by-one-until-empty. The later may be problematic from two points: (1) hitting the shared queue/mailbox matching logic once per response instead of once per Process() and (2) looping until empty is not clearly bounded -- imagining a condition where there's a thread trying to push a large influx of responses into the mailbox while at the same time we're trying to take from it until it's empty.
This commit is contained in:
parent
eda7610806
commit
69eee058c1
1 changed files with 7 additions and 3 deletions
|
@ -936,11 +936,15 @@ void Manager::Process()
|
|||
|
||||
for ( auto& s : data_stores )
|
||||
{
|
||||
while ( ! s.second->proxy.mailbox().empty() )
|
||||
auto num_available = s.second->proxy.mailbox().size();
|
||||
|
||||
if ( num_available > 0 )
|
||||
{
|
||||
had_input = true;
|
||||
auto response = s.second->proxy.receive();
|
||||
ProcessStoreResponse(s.second, move(response));
|
||||
auto responses = s.second->proxy.receive(num_available);
|
||||
|
||||
for ( auto& r : responses )
|
||||
ProcessStoreResponse(s.second, move(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue