Redo the body of event::Run() so that we don't hold the lock while actually processing the packets. Only around queue manipulation. Should free up analysis thread.
parent
c6f4af0dca
commit
305042ed67
|
@ -729,22 +729,24 @@ void Event::Run() {
|
||||||
if (storage != monitor->getStorage())
|
if (storage != monitor->getStorage())
|
||||||
delete storage;
|
delete storage;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lck(packet_queue_mutex);
|
|
||||||
|
|
||||||
// The idea is to process the queue no matter what so that all packets get processed.
|
// The idea is to process the queue no matter what so that all packets get processed.
|
||||||
// We only break if the queue is empty
|
// We only break if the queue is empty
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!packet_queue.empty()) {
|
ZMLockedPacket * packet_lock = nullptr;
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lck(packet_queue_mutex);
|
||||||
|
|
||||||
|
if (packet_queue.empty()) {
|
||||||
|
packet_queue_condition.wait(lck);
|
||||||
|
if (terminate_ or zm_terminate) break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Packets on this queue are locked. They are locked by analysis thread
|
// Packets on this queue are locked. They are locked by analysis thread
|
||||||
const ZMLockedPacket * packet_lock = packet_queue.front();
|
packet_lock = packet_queue.front();
|
||||||
this->AddPacket_(packet_lock->packet_);
|
|
||||||
delete packet_lock;
|
|
||||||
packet_queue.pop();
|
packet_queue.pop();
|
||||||
} else {
|
} // end lock scope
|
||||||
if (terminate_ or zm_terminate) {
|
this->AddPacket_(packet_lock->packet_);
|
||||||
break;
|
delete packet_lock;
|
||||||
}
|
} // end while
|
||||||
packet_queue_condition.wait(lck);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // end Run()
|
} // end Run()
|
||||||
|
|
Loading…
Reference in New Issue